In my database I have changed the type of a field from VARCHAR to DECIMAL. Therefore I have change the type in the java model class from String to BigDecimal.
In my previous XML validation file I have a requiredString fieldValidator. If I leave it, everytime I enter the value (a big decimal) in the form field, the requiredString fieldValidator fires. (maybe a problem with the param interceptor that should convert String to BigDecimal).
Anyway for the same field, I have another field validator which is a REGEX.
So I thought that if I dont use the requieredString, just the regex validator it would work, but not. If i dont fill the field up, no error fires.
So.. to sum up :
my action has a field from the Beneficiary class.
In the Beneficiairy class I have a BigDecimal field.
my xml validation file is like that for this field :
<field name="benef.nirBenef">
<field-validator type="regex">
<param name="expression"><![CDATA[^(1|2)\d{14}$]]></param>
<message key="error.securityNumber"/>
</field-validator>
when the field is empty, the validation says it is all right.
why ?
when if I use the requiredstring validator, the validation says it is wrong even though the value is good
Thank you
I found it…it is the same thing for any objects..
*/ Create a file saying what field(s) is/are complex
Name of the file : name_of_the_action-conversion.properties
for example my action class is BenefInfos.java, so my properties file is : BenefInfos-conversion.properties
the value is the name of my converter class BigDecimalConverter in model package
*/ Create BigDecimalConverter.java
}
*/Now if you want to VALIDATE, you have to create your own validator. To do so :
*/ add validators.xml to declare your own validator :
*/Create the validator class (here it is SocialSecurityValidator)
}
*/ and finally in the validation xml file you use your own validator.
Hope this is helpful