minLength static method

String? Function(String?) minLength(
  1. int n, {
  2. String? message,
})

Returns a validator that enforces minimum length.

Implementation

static String? Function(String?) minLength(int n, {String? message}) {
  return (value) {
    if (value == null) return null;
    if (value.length < n) {
      return message ?? 'Must be at least $n characters';
    }
    return null;
  };
}