AbstractStringValidator validation

I want to validate textfields, one of my validation should be an empty string validation, but:

why is calling isValidString() only when myTextFiled is not empty?

How implemented an empty string validation on the right way?


This is the way the validation system works in current versions of Vaadin: validators are not called if the field is empty (see e.g. AbstractField.validate()). If the field is required, an empty value results in a validation error. Otherwise, an empty field is always accepted.

This approach does have some limitations, so it is possible that it might change in some future major version, but that would cause problems with backwards compatibility so it needs very careful consideration.

You could override AbstractField.validate() and AbstractField.isValid() if necessary to change the behavior if necessary.

O.K. I understand, thanks!