validator method

  1. @override
AmountError? validator(
  1. String value
)
override

A function that must return a validation error if the provided value is invalid and null otherwise.

Implementation

@override
AmountError? validator(String value) {
  if (value.isEmpty == true || value == "") {
    return AmountError.empty;
  }
  return _amountRegExp.hasMatch(value) && value.length < 10
      ? null
      : value.isEmpty
          ? null
          : AmountError.invalid;
}