maxLengthValidator function
Implementation
ValidatorsFunction<FormControl<String>> maxLengthValidator(int maxlength,
{String? message, eventType = ValidationEventTypes.Error}) {
message = message ?? "Максимальная длина $maxlength";
return (FormControl<String> control) async {
if (control.value == null || control.value.length <= maxlength) {
return [];
}
return [
ValidationEvent(
key: maxLengthValidatorKey,
message: message!,
type: eventType,
)
];
};
}