maxLength static method
Returns a validator that enforces maximum length.
Implementation
static String? Function(String?) maxLength(int n, {String? message}) {
return (value) {
if (value == null) return null;
if (value.length > n) {
return message ?? 'Must be at most $n characters';
}
return null;
};
}