MaxLengthValidator constructor
A validator that checks if the length of a string value is less than or equal to a specified maximum length.
This validator is used to validate string values and returns an error message if the length of the value exceeds the specified maximum length.
Example usage:
final validator = MaxLengthValidator('Maximum length exceeded', 10);
String? result = validator.validate('Hello World');
print(result); // Output: 'Maximum length exceeded'
result = validator.validate('Hello');
print(result); // Output: null
Implementation
const MaxLengthValidator(this.maxLength, [super.errorMessage]);