EqualLengthValidator constructor

const EqualLengthValidator(
  1. int length, [
  2. String? errorMessage
])

A validator that checks if the length of a value is equal to a specified length. This validator is used to validate strings and other types that have a length property. It returns an error message if the value is not equal to the specified length. The length parameter specifies the desired length that the value should have. Example usage:

final validator = EqualLengthValidator(10,'Value must be equal to 10');
String? result = validator.validate("test");
print(result); // 'Value must be equal to 10'

Implementation

const EqualLengthValidator(this.length, [super.errorMessage]);