Skip to content

Commit

Permalink
Fields named email have emailValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
sprevilla committed Sep 2, 2019
1 parent 566e4d5 commit b88c349
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.vaadin.data.Validator;
import com.vaadin.data.converter.LocalDateToDateConverter;
import com.vaadin.data.converter.StringToIntegerConverter;
import com.vaadin.data.validator.EmailValidator;
import com.vaadin.data.validator.RegexpValidator;
import com.vaadin.data.validator.StringLengthValidator;
import com.vaadin.ui.*;
Expand Down Expand Up @@ -192,6 +193,14 @@ public List<Validator> getValidators(String propertyId) {
validators.add(new RegexpValidator(getApp().getMessage("errorMessage.invalidField", getApp().getMessage(propertyId)),regex));
if (length > 0)
validators.add(new StringLengthValidator(getApp().getMessage("errorMessage.invalidField", getApp().getMessage(propertyId)),0,length));
if ("email".equals(propertyId)) {
validators.add(new EmailValidator(getApp().getMessage("errorMessage.invalidEmail")) {
@Override
protected boolean isValid(String value) {
return value == null || value.isEmpty() || super.isValid(value);
}
});
}
}
return validators;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,6 @@ public FieldFactory createFieldFactory() {
return new FieldFactory(getBean(), getViewConfig(), getBinder()) {
public List<Validator> getValidators(String propertyId) {
List<Validator> list = super.getValidators(propertyId);
if ("email".equals(propertyId)) {
list.add(new EmailValidator(getApp().getMessage("errorMessage.invalidEmail")) {
@Override
protected boolean isValid(String value) {
return value == null || value.isEmpty() || super.isValid(value);
}
});
}
if ("nick".equals(propertyId)) {
list.add(((UsersHelper)getHelper()).getNickTakenValidator());
}
Expand Down

0 comments on commit b88c349

Please sign in to comment.