isbnValidator static method
isbnValidator to validate ISBN (International Standard Book Number)
validator: (value) => SimpleValidations.isbnValidator(value, [errorMessage]),
Implementation
static String? isbnValidator(String? value, [String? errorMessage]) {
RegExp regex = CustomRegEx.isbnRegex;
if (value == null || value.isEmpty) {
return errorMessage ?? 'Required';
} else if (!regex.hasMatch(value)) {
return errorMessage ?? 'Please enter a valid ISBN';
}
return null;
}