minLength static method

String? minLength(
  1. String? value,
  2. int min, {
  3. String? fieldName,
})

Validates minimum string length.

Implementation

static String? minLength(String? value, int min, {String? fieldName}) {
  if (value == null || value.isEmpty) {
    return null; // Don't validate empty values
  }

  if (value.length < min) {
    return '${fieldName ?? "This field"} must be at least $min characters long.';
  }

  return null;
}