validator method

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

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

Implementation

@override
IdUserError? validator(String value) {
  if (value.trim().isEmpty) return IdUserError.empty;
  if (!_digitsOnly.hasMatch(value)) return IdUserError.format;
  if (value.length > maxLength) return IdUserError.tooLong;
  return null;
}