Hello,
I didn't found a satisfying way to integrate Hibernate Validator with Spring org..validation.Validator interface.
I think this integration could be usefull (Spring Batch already has ValidatingItemReader, Spring MVC has validation support, and we could use validation support in methodInterceptor).
I've found 2 solutions :
using Spring Modules Hibernate Validator Integration.
making my own implementation of Hibernate Validator.
Using Spring Modules, I cannot have access to the validation message (I only get default message = {validator.length} and error code = LignePortefeuillePk.cedetr[{validator.length}]).
Using my own implementation of Hibernate Validator, I cannot have access to the error code (less important I think for a validation error). I get here default message = la longueur doit être entre 3 et 5.
Has someone already found a solution ?
I'll attach some sample code of my custom Hibernate Validator.
blog...rameworks.html
Thanks for the sample !
To resume, Spring Modules / Hibernate Validator bridge isn't satisfying since we cannot access the message resolved by Hibernate Validator.
To use Hibernate Validator, we must use a custom solution (such as your link).
N.B. : error code will always be missing but since we do not use it in validation errors this is ok.
FYI - the validator from blog...rameworks.html doesn't manage i18n.
I'll keep my own for the moment. |