maxLength method
FormFieldValidator
that requires the length of the field's value to be
less than or equal to the provided maximum length.
Implementation
static FormFieldValidator maxLength(
num maxLength, {
String errorText,
}) {
return (valueCandidate) {
if (valueCandidate != null && valueCandidate.length > maxLength) {
return errorText ??
"Value must have a length less than or equal to $maxLength";
}
return null;
};
}