Java Spring Annotations and Validation: A question.

null

...
Joined
Nov 12, 2014
Messages
31,244
Reputation
5,478
Daps
49,088
Reppin
UK, DE, GY, DMV
Does anyone here know Spring?

I am seeing a difference between how automated validation (@Valid DTO name, BindingRequest) and manual validation work.

Manual validation by injected validator catches errors (against annotated constraints in DTO class) that automated validated misses.

So bindingResult has no errors when automated but Set<ConstraintViolation<>> is non empty when called on the same object using injected validator.validate(name)

Is this normal?
 

null

...
Joined
Nov 12, 2014
Messages
31,244
Reputation
5,478
Daps
49,088
Reppin
UK, DE, GY, DMV
A: no it is not normal.

<mvc:annotation-driven/> has to go in the application context for automated checking to work properly

:hubie:
 
Top