validate method

  1. @override
String? validate(
  1. String? value
)
override

Validates the given value and returns an error message if the value is invalid.

Implementation

@override
String? validate(String? value) {
  assert(minWordCount > 0, 'The minimum words count must be greater than 0');
  if (value != null && value.isNotEmpty) {
    final words = value.trim().split(' ');
    if (words.length < minWordCount) {
      return getErrorMessage(
        EasyValidatorMessages.instance.minWordCount,
        minWordCount.toString(),
      );
    }
  }
  return null;
}