validator method
A function that must return a validation error if the provided
value is invalid and null otherwise.
Implementation
@override
RequiredTextError? validator(String value) {
final trimmed = value.trim();
if (trimmed.isEmpty) return RequiredTextError.empty;
if (trimmed.length < minLength) return RequiredTextError.tooShort;
if (maxLength != null && trimmed.length > maxLength!) {
return RequiredTextError.tooLong;
}
return null;
}