notContainSpacesValidator function

ValidatorsFunction<FormControl<String>> notContainSpacesValidator({
  1. String message = 'Не должен содержать пробелы',
  2. dynamic eventType = ValidationEventTypes.Error,
})

Not contain spaces Не содержит проблелов

Implementation

ValidatorsFunction<FormControl<String>> notContainSpacesValidator(
        {String message = 'Не должен содержать пробелы',
        eventType = ValidationEventTypes.Error}) =>
    (FormControl<String> control) async {
      if (control.value == null ||
          RegExp(r"\s").allMatches(control.value).isEmpty) {
        return [];
      }
      return [
        ValidationEvent(
          key: notContainSpacesValidatorKey,
          message: message,
          type: eventType,
        )
      ];
    };