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?
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.
the
javax.validation.constraints.NotBlank
is part of Bean Validation 2.0 and validator for it is not present in 5.3 series.as baeldung.com say Per the JSR 380 specification, the validation-api dependency contains the standard validation APIs:
Hibernate Validator is the reference implementation of the validation API. To use it, we must add the following dependencies: