numericWithSpaceValidator static method

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

numericWithSpaceValidator to validate a number

validator: (value) => SimpleValidations.numericWithSpaceValidator(value, [errorMessage]),

Implementation

static String? numericWithSpaceValidator(String? value,
    [String? errorMessage]) {
  RegExp regex = CustomRegEx.numericWithSpaceRegex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Only numeric characters and space is allowed';
  }
  return null;
}