Hello all together,
i am using Vaadin 8.1 and have a Problem. I am using an EmailValidator together with a Binding. But the validation should only occur, if the email is not empty (cause email is not required in my case). How can I do that?
Here’s my code:
binder.forField(email)
.withValidator(new EmailValidator("Ungültige Email-Adresse"))
.bind(MyBean::getEmpfaengerEmail, MyBean::setEmpfaengerEmail);
form.addComponent(email);
NativeButton btn = new NativeButton("submit");
btn.addClickListener(e -> {
MyBean dataBean = new MyBean(domain);
try {
binder.writeBean(dataBean);
...
} catch (ValidationException e1) {
Notification.show("Bitte korrigieren Sie die fehlerhaften Eingaben.");
}
});