minLength static method

String? Function(String?) minLength(
  1. int length, [
  2. String? message
])

Minimum length

Implementation

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