validator static method
validator for all text and string values
Implementation
static String? validator({String? value, required Pattern pattern, String? errorMessage}) {
final notEmpty = value?.trim().isNotEmpty;
if (notEmpty != null) {
return hasMatch(value: value?.trim(), pattern: pattern)
? null
: notEmpty
? (errorMessage ?? '')
: "Cannot be empty";
} else {
return errorMessage ?? '';
}
}