maxLength method Null safety
Returns a Validator that accepts a value that is shorter or of equal length to length
.
If the value is null, its length is treated as zero.
If trim
is true
leading and trailing spaces will be ignored.
Implementation
Validator maxLength(
int length, {
bool trim = false,
String message = "Validator.maxLength",
}) {
return add(
(value) {
var v = trim ? (value ?? "").trim() : (value ?? "");
return v.length > length ? message : null;
},
);
}