BeanValidator issue

I’ve this dependecy already
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency>

and in the domain class I’ve this @NotBlank private String customerName; so I’m not specifying the asRequired() in the binder because as per the doc, it should be shown as requied by default. But this is not happening. I see the field without the requried indicator ? What could be the issue ?

I can’t find mentions of @NotBlank annotation in the docs.

By default, @NotNull, @NotEmpty and @Size (if min() value is greater than 0) configures the field as required
What documentation are you referring?

I’ve both ``

@NotEmpty @NotBlank private String customerName;

this is the doc link

And you confirm that you are using the BeanValidationBinder, not the default Binder

yes I confirm private final BeanValidationBinder<CustomerEntity> customerEntityBinder = new BeanValidationBinder<>(CustomerEntity.class);

I tried and I can see the indicator.
Just to be sure, does your TextField have a label set?

private final TextField customerName = new TextField(“Customer Name”);


Seems all correct. Can you post the whole CustomerEntity class and the class that uses the binder?


message.txt (2.96 KB)


message.txt (3.43 KB)

If you use forField no magic applies.

that means, it works only for bindInstanceFields(this) ?

“If you use Java Specification Requests (JSR) 303 validators, you should use BeanValidationBinder. It picks validators automatically when using bindInstanceFields().”

As described in the docs, yes :sweat_smile:

good to know