Issue
I have requirement that in common api module(multi module project) I can't use any kind of hibernate's validation annotations, so I did use one from javax.validation which is acceptable.
Problem starts when I want to validate my domain objects(I use vaadin) that contains NotBlank annotation. I get the following exception
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.String'. Check configuration for 'name'
Validation is invoked by call
Validation.buildDefaultValidatorFactory().validateValue(beanType, propertyName, value)
Same code works perfectly with hibernate's NotBlank
Also @Size @NotNull from javax works fine.
Is it possible to provide NotBlank validator implementation to DefaultValidatorFactory?
Am I missing some dependency? (I have hibernate-validator already)
Does NotBlank from javax works the same as NotBlank from hibernate(I mean does it validate strings?)
How to solve this?
Solution
The problem is in the version you are using then. You need to update to 6.0.x series. With the current latest been 6.0.9. Note that the groupId is changed to org.hibernate.validator.
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.9.Final</version>
</dependency>
the javax.validation.constraints.NotBlank
is part of Bean Validation 2.0 and validator for it is not present in 5.3 series.
Answered By - mark_o
Answer Checked By - Cary Denson (JavaFixing Admin)