Hi Frederic,
there's only the sameAs() constraint that does property-value
comparison in a bean. However, you don't need a constraint to perform
validation.
You can very easily add your own validation rule, for example:
.addRule(new AbstractValidationRule() {
public boolean validate() {
Couple bean = (Couple)getBean();
return bean.getPerson1Id() == bean.getPerson12d();
}
public ValidationError getError() {
return new ValidationError.INVALID("person1Id");
}
})
Hope this helps,
Geert
On 02 Sep 2006, at 05:08, [EMAIL PROTECTED] wrote:
Hi all,
I have a simple problem for which I can't seem to find a solution
despite searching the wiki and the maillist archives. This of course
doesn't mean the answer isn't in there, I just can't seem to find it
:(
Say I have a POJO, "Person", with an Integer id, first name, last name
(Strings), etc.
Another POJO, "Couple", represents a union between two persons (such
as marriage).
So in Couple I have person1Id and person2Id, which refer to the id's
of the Person's that form the Couple.
I implement the constraints for Person and Couple in separate MetaData
classes, and it mostly works except that I can't figure out how to
have the following constraint: person1Id != person2Id.
I tried this but it doesn't work:
addConstraint(new ConstrainedProperty("person1Id")
.notNull(true)
.manyToOne(Person.class, "id")
);
addConstraint(new ConstrainedProperty("person2Id")
.notNull(true)
.manyToOne(Person.class, "id")
.notEqual(((Couple) retrieveValidatedBean()).getPerson1Id())
);
Generally speaking I can't seem to be able to validate a property
against the value of another property. For example the Person class
has dates for birth and deceased (if applicable), and ideally I want
to validate that the date of deceased is after the date of birth.
One last question, I don't know either how I would validate that a
Couple doesn't already exist in the database, i.e. that the
combination of person1Id and person2Id must be unique.
Anyone can help?
Thanks in advance!
Frederic
--
[EMAIL PROTECTED]
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users
--
Geert Bevin
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users