maxLength static method

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

Validates that the value has maximum length

Example:

Validators.maxLength(value, 100);

Implementation

static String? maxLength(String? value, int maxLength, {String? message}) {
  if (value == null || value.isEmpty) return null;
  if (value.length > maxLength) {
    return message ?? 'Must be at most $maxLength characters';
  }
  return null;
}