mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 13:17:56 +00:00
display multiple error
This commit is contained in:
@@ -58,31 +58,39 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
|
||||
/////////////////////////////////////VALIDATORS/////////////////////////////////////
|
||||
String? passwordValidator(String? value) {
|
||||
List<String> errors = [];
|
||||
|
||||
if (value == null || value.isEmpty) {
|
||||
return "Please enter your password";
|
||||
errors.add("Please enter your password");
|
||||
}
|
||||
|
||||
if (value.length < 8) {
|
||||
return 'Password must be at least 8 characters long';
|
||||
if (value != null && value.length < 8) {
|
||||
errors.add('Password must be at least 8 characters long');
|
||||
}
|
||||
|
||||
if (!RegExp(r'[a-z]').hasMatch(value)) {
|
||||
return 'Password must contain at least one lowercase letter';
|
||||
if (value != null && !RegExp(r'[a-z]').hasMatch(value)) {
|
||||
errors.add('Password must contain at least one lowercase letter');
|
||||
}
|
||||
|
||||
if (!RegExp(r'[A-Z]').hasMatch(value)) {
|
||||
return 'Password must contain at least one uppercase letter';
|
||||
if (value != null && !RegExp(r'[A-Z]').hasMatch(value)) {
|
||||
errors.add('Password must contain at least one uppercase letter');
|
||||
}
|
||||
|
||||
if (!RegExp(r'\d').hasMatch(value)) {
|
||||
return 'Password must contain at least one number';
|
||||
if (value != null && !RegExp(r'\d').hasMatch(value)) {
|
||||
errors.add('Password must contain at least one number');
|
||||
}
|
||||
|
||||
if (!RegExp(r'[!"#$%&()*+,-./:;<=>?@[\]^_`{|}~]').hasMatch(value)) {
|
||||
return 'Password must contain at least one special character';
|
||||
if (value != null &&
|
||||
!RegExp(r'[!"#$%&()*+,-./:;<=>?@[\]^_`{|}~]').hasMatch(value)) {
|
||||
errors.add('Password must contain at least one special character');
|
||||
}
|
||||
|
||||
return null;
|
||||
if (errors.isNotEmpty) {
|
||||
return errors
|
||||
.join('\n'); // Join the errors with new lines to show all at once
|
||||
}
|
||||
|
||||
return null; // No errors
|
||||
}
|
||||
|
||||
String? fullNameValidator(String? value) {
|
||||
|
||||
Reference in New Issue
Block a user