Skip to content

Commit 9ab7253

Browse files
committed
Docs
1 parent d1c1c0f commit 9ab7253

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

lib/src/utils/validators.dart

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,46 @@ RegExp _bic = RegExp(r'^[A-Z]{4}[A-Z]{2}\w{2}(\w{3})?$');
160160
RegExp _time = RegExp(
161161
r'^(?:[01]\d|2[0-3]):[0-5]\d$|^(?:0?[1-9]|1[0-2]):[0-5]\d\s?(?:[AaPp][Mm])$');
162162

163+
/// {@template upper_case_template}
164+
/// This regex matches any character that is not an uppercase letter (A-Z) or Ñ.
165+
///
166+
/// - It includes special characters, digits, and lowercase letters.
167+
/// - It can be used to find non-uppercase characters.
168+
///
169+
/// Examples: a, 1, @
170+
/// {@endtemplate}
171+
RegExp _upperCase = RegExp(r'[^A-ZÑ]');
172+
173+
/// {@template lower_case_template}
174+
/// This regex matches any character that is not a lowercase letter (a-z) or ñ.
175+
///
176+
/// - It includes special characters, digits, and uppercase letters.
177+
/// - It can be used to find non-lowercase characters.
178+
///
179+
/// Examples: A, 1, @
180+
/// {@endtemplate}
181+
RegExp _lowerCase = RegExp(r'[^a-zñ]');
182+
183+
/// {@template number_template}
184+
/// This regex matches any character that is not a digit (0-9).
185+
///
186+
/// - It includes special characters, letters, and other non-numeric characters.
187+
/// - It can be used to find non-digit characters.
188+
///
189+
/// Examples: a, A, @
190+
/// {@endtemplate}
191+
RegExp _number = RegExp(r'[^0-9]');
192+
193+
/// {@template special_char_template}
194+
/// This regex matches any character that is not a letter (A-Z, a-z) or a digit (0-9).
195+
///
196+
/// - It includes special characters and symbols.
197+
/// - It can be used to find non-alphanumeric characters.
198+
///
199+
/// Examples: @, #, %
200+
/// {@endtemplate}
201+
RegExp _specialChar = RegExp(r'[A-Za-z0-9]');
202+
163203
int _maxUrlLength = 2083;
164204

165205
/// check if the string [str] is an email
@@ -471,19 +511,19 @@ bool isColorCode(String value,
471511
}
472512

473513
int uppercaseCharLength(String value) {
474-
return value.replaceAll(RegExp(r'[^A-ZÑ]'), '').length;
514+
return value.replaceAll(_upperCase, '').length;
475515
}
476516

477517
int lowercaseCharLength(String value) {
478-
return value.replaceAll(RegExp(r'[^a-zñ]'), '').length;
518+
return value.replaceAll(_lowerCase, '').length;
479519
}
480520

481521
int numberCharLength(String value) {
482-
return value.replaceAll(RegExp(r'[^0-9]'), '').length;
522+
return value.replaceAll(_number, '').length;
483523
}
484524

485525
int specialCharLength(String value) {
486-
return value.replaceAll(RegExp(r'[A-Za-z0-9]'), '').length;
526+
return value.replaceAll(_specialChar, '').length;
487527
}
488528

489529
bool isAlphabetical(String value) {

0 commit comments

Comments
 (0)