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.  [ 1 post ] 
Author Message
 Post subject: Validation acrros Multiple fields
PostPosted: Wed Sep 19, 2007 10:38 am 
Newbie

Joined: Wed Sep 19, 2007 10:05 am
Posts: 3
Hi,

I have quite a simple issue:
One entity (let's name it History) has 2 fields:
Date validFrom;
Date validTo;

I want to ensure that validTo is [u]after[/u] validFrom.

My first idea was to define my own field validator that I put on validTo but I can only access the value from the property itself, thus not possible to inspect validFrom...

Of course I can write a method like that:
@AssertTrue
public boolean validateToAfterFrom() {
return validTo.after(validFrom);
}


but then the validation is entity wide and I cannot know on my screen that I have to write an error message on validTo specifically...


Any solution to this problem that seems really standard ??
(either be able to inspect the whole entity or be able to specify on which field an AssertTrue function works)


Thx very much

vincent

[b]Hibernate version: 3.2.2 GA[/b]
[b]Hibernate Validator version: 3.0.0 GA[/b]
[/u]


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

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.