passportValidator static method
passportValidator to validate a passport number
validator: (value) => SimpleValidations.passportValidator(value, [errorMessage]),
Implementation
static String? passportValidator(String? value, [String? errorMessage]) {
RegExp regex = CustomRegEx.passportRegex;
if (value == null || value.isEmpty) {
return errorMessage ?? 'Required';
} else if (!regex.hasMatch(value)) {
return errorMessage ?? 'Please enter a valid passport number';
}
return null;
}