Validators vs bean validation

In the docs it is said …
The validation state of each field is updated whenever the user modifies the value of that field.
So if i have a validator registered in a textfield wich is binded to a property I can see the error message after i wrote the name field with less than 4 characters.

Binder<Person> binder = new Binder<>();
TexField name = new TextField();
      .withValidator( n -> n.length() < 4,
                      "name must have at least 4 characters")
      .bind(Person::getName, Person::setName)


But if i use bean validation i can’t see the same.

@Size(min = 4, message = "name must have at least 4 characters")
String name

BeanValidationBinder<Person> binder = new BeanvalidationBinder<>(Person.class); binder.bindInstanceFields(form); I thougth that it was the same because BeabValidationBinder extends Binder.
So in that case when does it happen the validation?

Do you have a Java Bean Validation implementation in your classpath? For example:


In my POM i have the next dependency

<dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.0.Final</version> </dependency> I believed that it was enough.

Yes, javax.validation is valid alternative to org.apache.bval. But you need to have implementation in addition to API, e.g.

org.hibernate hibernate-validator …

Vaadin Binder support JSR-303 versions 1.0 and 1.1, you need to double check that too.

Apache Bval
is an implementation.

So, Java Validation API is a specification (that’s the

dependency). You need also an implementation. Two popular implementations are the ones provided by Apache (the dependencies I posted), and Hibernate (the ones Tatu posted). Let us know if it works!

It doesn´t work, something escape me!!!
I have in the POM the two dependencies (api and implementation of bean validation)

<dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.0.Final</version> </dependency> <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> <version>6.0.5.Final</version> </dependency> What is the moment in wich the validation trigger the error message?
After the user update the field (that it was happening with .withvalidator.
In the doc it is said …

Bean level validation can only be performed once the bean has been updated. This means that this functionality can only be used together with setBean. I am not sure what bean level means. My annotation is in the property name of the bean person.

“Bean level validation” are constraints at the class level. So I guess, it’s not your case (you have a field-level constraint: @Size). With Hibernate Validator you also need this if you are not deploying your app in a JEE container:

<dependency> <groupId>org.glassfish</groupId> <artifactId>javax.el</artifactId> <version>3.0.1-b08</version> </dependency> If that doesn’t work, are you able to share the complete
file and relevant Java classes?

when you write about JEE container a ligth turned it on. I use wildfly so i use the bean validation provided by wildfly.


Now it works but i was surprised about the * in the fields with annotation. It appears first * (like required) and ! (when the user begin to write the three first characters).
What is the meaning of this *? It isnt required beacause the only annotation was @Size.

Ups !!!
It doesn’t work with same annotations like @NotNull but it works with others like @Size ???

It should work for all of them. Did you configure a “null representation”? Also, double check you imported the correct
annotation (


Thank you Alejandro,
hibernate-validator is enough with a JEE container (wildfly) and withNotNullRepresentation(“”) at least works @NotNull constraint