-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Context Based Validation
PostPosted: Mon May 21, 2007 7:23 am 
Newbie

Joined: Mon May 21, 2007 2:18 am
Posts: 2
Hi Folks,

I am using Hibernate Validator to do the Domain model validation in our application and I have a couple of requirements that doesn't seem to supported (I could be wrong though). My domain object is created and persisted via one of the following ways :-
1) Wizard like Web UI
2) Excel file upload
3) Syncing from another system

While creating the domain object via option 2 & 3 I can apply the complete set of validations at once because I would be constructing the entire object at once (basically all the data required to create a valid domain object is available together). This logic cannot be applied to the domain when it is created via option 1 - Wizard screens. Each page of the wizard has to validated just for entries made on that page. Since I have my domain validations in place I would like to reuse them rather than writing the same validations in xml files for the web layer(struts/webwork validator). I am looking for a context based validation where validations are picked up based on some context.

For example lets say the first page saves the object to a draft state and the second page completes the object. Then when I annotate an Element for validation, I should be able to provide a context say (draft/submit) so that on the draft page the domain is validate only for validation checks that are of a 'draft' context. An Element could be part of many contexts and there should be an 'ALL' context during which all the validations are picked up. Can we do something like this in Hibernate Validator?. If not, how can I go about to achieve this?.

Of course there are other problems to worry about like Validators that pushes constraints to the database should be made to ignore the constraint push if a context other than 'ALL' is provided to them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 6:35 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I see two solutions:
- use the per property validation API validator.getInvalidValues(Object, String propertyName)
- implement a real contextual validation in Hibernate Validator

I have some ideas on how it could be described if you're ready to contribute.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 5:00 am 
Newbie

Joined: Mon May 21, 2007 2:18 am
Posts: 2
Hi Emmanuel,

Option 1 is not really an option :)

Option 2 is something I am interested in and I am willing to contribute towards this.

Let me know how we can go about doing this.

Thanks,
Vineeth.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 9:52 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I wrote down my ideas on the subject
http://opensource.atlassian.com/projects/hibernate/browse/HV-22

If you could come up with a patch for that, that would be interesting, he idea need to be polished probably.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 15, 2007 6:07 pm 
Beginner
Beginner

Joined: Fri Nov 03, 2006 3:21 pm
Posts: 30
vote for this!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.