[hibernate-issues] [Hibernate-JIRA] Created: (ANN-514) Validator doesn't support validation based on value of other fields in the object

Rakesh Kalra (JIRA) noreply at atlassian.com
Thu Dec 21 20:13:05 EST 2006


Validator doesn't support validation based on value of other fields in the object
---------------------------------------------------------------------------------

         Key: ANN-514
         URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-514
     Project: Hibernate Annotations
        Type: Improvement

  Components: validator  
    Versions: 3.2.1    
 Environment: Hibernate Annotations 3.2.1
    Reporter: Rakesh Kalra


I really like Hibernate Validator. In the absense of this framework, I was going to write something similar.

But, I see a major limitation. If validation of a field depends on the value of another field in the same object, 
hibernate validator doesn't have a way to handle this.

The simplest example is when the validator is used for forms. Forms sometimes have fields like "email" and "retypeEmail". 
It would be great to be able to write a custom annotation:

  @Match(property="retypeEmail")
  public String getEmail(){
    return email;
   }

where, getRetypeEmail() is also available in the same object.

Another example is where validation of a credit card number, depends on the credit card type

This feature can be implemented, by exposing the object being validated to the isValid() method. 
Without changing the signature of this method, the object can be exposed via some kind
of a ValidationContext object, which is stored as a ThreadLocal variable.

Please let me know the best work around, until this feature can be implemented.

Regards,
Rakesh


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list