alphaCharactersWithSpaceValidator static method
alphaCharactersWithSpaceValidator to validate if a form field contains alphabets and space
validator: (value) => SimpleValidations.alphaCharactersWithSpaceValidator(value, [errorMessage]),
Implementation
static String? alphaCharactersWithSpaceValidator(String? value,
[String? errorMessage]) {
if (value == null || value.isEmpty) {
return errorMessage ?? 'Required';
}
RegExp regex = CustomRegEx.alphaWithSpaceRegex;
if (!regex.hasMatch(value)) {
return errorMessage ?? 'Only alphabets and space is allowed';
}
return null;
}