exactLength static method

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

Validates that the value has exact length

Example:

Validators.exactLength(value, 10);

Implementation

static String? exactLength(String? value, int length, {String? message}) {
  if (value == null || value.isEmpty) return null;
  if (value.length != length) {
    return message ?? 'Must be exactly $length characters';
  }
  return null;
}