Hi all,
I am using Hibernate Validator as a JSR-303 validation provider and its xml style constraints descriptions.
So, I have a
Code:
<bean class="com.my.User" ignore-annotations="true">
  <field name="email">
         <constraint annotation="javax.validation.constraints.Pattern">
             <element name="regexp"><![CDATA[[A-Za-z0-9\._%+-]{1,64}@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}]]></element>
         </constraint>
  </field>
  .....
</bean>
I also have a separate class, which contains all my patterns
Code:
public final class Regexps {
  public static final String EMAIL_REGEXP = "A-Za-z0-9\._%+-]{1,64}@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}";
  ....
}
So, as you can see, I have two places, where email regexp is present, and I want only one place.
My question:
Is it possible  to use the 
public static final String EMAIL_REGEXP = "A-Za-z0-9\._%+-]{1,64}@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}" field inside the xml, so that
I could just refer to the contant string field.
So I would Like to have something like:
Code:
<bean class="com.my.User" ignore-annotations="true">
  <field name="email">
         <constraint annotation="javax.validation.constraints.Pattern">
             <element name="regexp">Regexps.EMAIL_REGEXP</element>
         </constraint>
  </field>
  .....
</bean>
By the way, it is possible via annotations
Code:
public class User {
   @Pattern(regexp = Regexps.EMAIL_REGEXP)   
   private String email;
}
But I cannot use annotations, because I use the legacy POJOs which I use for data transfering and cannot change the source code.