maxLength static method

String? maxLength(
  1. String? value,
  2. int length, {
  3. String fieldName = 'This field',
})

Validates that the input does not exceed a maximum length.

Implementation

static String? maxLength(
  String? value,
  int length, {
  String fieldName = 'This field',
}) {
  if (value != null && value.length > length) {
    return '$fieldName must be at most $length characters';
  }
  return null;
}