minLengthValidator function

String? minLengthValidator(
  1. String? value,
  2. int minLength, {
  3. String? message,
})

Field must be at least minLength characters (blank passes).

Implementation

String? minLengthValidator(String? value, int minLength, {String? message}) {
  if (value == null || value.trim().isEmpty) return null;
  return value.length >= minLength
      ? null
      : message ?? 'Must be at least $minLength characters';
}