MaxWordCountValidator constructor
A validator that checks if the number of words in a value is less than or equal to a specified maximum word count.
This validator is used to validate strings and other types that have a length property. It returns an error message if the value is longer than the specified maximum word count.
Example usage:
final validator = MaxWordCountValidator(2,'Value must have at most 2 words');
validator.validate('hello world'); // returns null
validator.validate('hello world hello'); // returns 'Value must have at most 2 words'
Implementation
const MaxWordCountValidator(this.maxWordCount, [super.errorMessage]);