hasSpecialChars static method
FormFieldValidator that requires the field's value to contain a minimum number of special characters.
Parameters:
atLeast
The minimum number of special characters (default: 1).regex
The regex pattern to match.errorText
The error message when the value does not contain the required number of special characters.checkNullOrEmpty
Whether to check for null or empty values.
This regex matches any character that is not a letter (A-Z, a-z) or a digit (0-9).
- It includes special characters and symbols.
- It can be used to find non-alphanumeric characters.
Examples: @, #, %
Implementation
static FormFieldValidator<String> hasSpecialChars({
int atLeast = 1,
RegExp? regex,
String? errorText,
bool checkNullOrEmpty = true,
}) => HasSpecialCharsValidator(
atLeast: atLeast,
regex: regex,
errorText: errorText,
checkNullOrEmpty: checkNullOrEmpty,
).validate;