Question

I am using bean-validation with apache bval as its implementation. (I do not want to use hibernate-validation or oval, because they have too much dependencies.)

First question: Is bval still maintained or is it orphaned?

Second question: Is it possible to implement custom validators using bval? E.g. a need a validator to File field that validates, that the file exists, isreadable and a file.

Was it helpful?

Solution

Apache BVal is afaik compliant with Bean Validation 1.0 which means should be able to write portable custom constraints. However, BVal is not yet Bean Validation 1.1 compatible, meaning you won't have executable constraints.

I don't know how active development is atm. Last release was in September 2012 which is quite a while back.

What is your concern with the Hibernate Validator or OVal dependencies?

OTHER TIPS

Somebody did a performance comparison. However I am not sure how objective this comparison is: http://soularis999.blogspot.com/2011/07/bean-validation-performance-evaluation.html

Theres a how to now on baeldung.com: https://www.baeldung.com/apache-bval, it looks pretty standard

  • define an new annotation describing your constraint
  • define an constraint validator which implements ConstraintValidator<CONSTRAINT, TARGET>
  • annotatate your annotation with @Constraint(validatedBy={Validator.class})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top