isbnValidator static method

String? isbnValidator(
  1. String? value, [
  2. String? errorMessage
])

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;
}