The moose likes Spring and the fly likes Spring validation framework applicabilty Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Spring
Reply Bookmark "Spring validation framework applicabilty" Watch "Spring validation framework applicabilty" New topic
Author

Spring validation framework applicabilty

Sujeet Kumar Jaiswal
Greenhorn

Joined: Mar 07, 2010
Posts: 17
Hi,
I am looking at feasibility of using Spring 3.1.0 validation framework to implement validation to all the API's that I have developed. In the service implementation layer, I need to add the validation to each of the service/functions in order to check if the passed params are valid and have correct values. What I found from initial investigation is that Spring's Validator Interface has to be implemented for each POJO's that I have.

- But it may happen that for the given service, as in my case, that during validation one POJO's property value's validity may depend on another passed POJO's property value. So basically, service's POJO param's are valid or not, It can be interdependent.
- Also, one POJO may have different validation logic in different services. May be I can allow one of it's property to be null in one case and not null in another cased for different services.

Is there any way to use Spring Validation framework in this case. If yes, how? If not, Please share if you have any other framework idea which will fit in my case.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16624

The Validator gets passed an Object, not a specific domain object. Which means you can create an object that holds both domain objects if the validation is about values from those two objects, then write your validator.

You can just create a wrapper object that holds onto both domain objects. Or if one of the domain objects already holds a reference to the other domain object, then pass the one domain object.

Think just Java, There are always solutions. You can also choose to use JSR 303 and @Valid if you want.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sujeet Kumar Jaiswal
Greenhorn

Joined: Mar 07, 2010
Posts: 17
Thanks Mark
 
IntelliJ Java IDE
 
subject: Spring validation framework applicabilty
 
Threads others viewed
Advantage of using Spring Framework
Need a framework for mapping/populate Domain Objects(POJOs) to Transfer Objects(also POJO)
How to Group a Collection of Pojo's based on some pojo property?
Passed !!!!
Passed Part One with 87%
MyEclipse, The Clear Choice