Is it possible to return conditional error message for a vaadin validator?
TextField textField = new TextField();
String regex = "?:(foo|bar)";
textField.addValidator(new RegexpValidator(regex, true, getErrorMessage()));
I want to have a different error message depending on what the user write in the textField.
I found the solution. One should just override the getErrorMessage of the validator
textField.addValidator(new RegexpValidator(regex, true, "") {
@Override
public String getErrorMessage() {
return setMessage();
}
});