maxLength static method
Validates maximum string length.
Implementation
static String? maxLength(String? value, int max, {String? fieldName}) {
if (value == null || value.isEmpty) {
return null;
}
if (value.length > max) {
return '${fieldName ?? "This field"} must not exceed $max characters.';
}
return null;
}