currencyValidator static method

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

currencyValidator to validate currency

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

Implementation

static String? currencyValidator(String? value, [String? errorMessage]) {
  RegExp regex = CustomRegEx.currencyRegex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter a valid currency amount';
  }
  return null;
}