shashikanthb
shashikanthb

Reputation: 379

Errors object required in invoking Spring validation

I am working on a application using spring. i want to use spring validation framework for validating different domain/model objects from the service layer which has the validator injected. I am planning to use ValidationUtils to invoke validator, but i am not sure what implementation of errors i need to pass to the invokeValidator method.

Signature in ValidationUtils:

  invokeValidator(Validator validator, Object obj, Errors errors) 

Will it be right to use BeanPropertyBindingResult.

  BeanPropertyBindingResult result = new BeanPropertyBindingResult(javaProduct, "javaProduct");

Upvotes: 1

Views: 352

Answers (1)

Japan Trivedi
Japan Trivedi

Reputation: 4483

Yes ofcourse. You can pass object of BeanPropertyBindingResult object to the Errors.

It is implements the interface Errors.

Hope this helps you. Cheers.

Upvotes: 1

Related Questions