10/30/2008

valangValidator script example

<bean id="registrationValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value><![CDATA[
{ userName : ? is not blank : 'User Name: required.' }
{ userName : matches('\\w+',?) == true: 'User Name: Only Alpha-Numeric Characters' }
{ userName : matches('\\w+',?) == true: 'User Name: Only Alpha-Numeric Characters' }
{ userName : length(?) > 6 : 'User Name: Not between 6 - 12 characters.' }
{ userName : length(?) < 12 : 'User Name: Not between 6 - 12 characters.' }
{ firstName : ? is not blank : 'First Name: required.' }
{ firstName : matches('\\w+',?) == true: 'First Name: Only Alpha-Numeric Characters' }
{ lastName : ? is not blank : 'Last Name: required.' }
{ lastName : matches('\\w+',?) == true: 'Last Name: Only Alpha-Numeric Characters' }
{ email : ? is not blank : 'E-Mail: required.' }
{ email : email(?) == true: 'E-Mail: Not A valid Address' }
{ password : ? is not blank : 'Password: required.' }
{ password : matches('\\w+',?) == true: 'Password: Only Alpha-Numeric Characters' }
{ password : length(?) > 6 : 'Password: Not between 6 - 12 characters.' }
{ password : length(?) < 12 : 'Password: Not between 6 - 12 characters.' }
{ confirmPassword : ? is not blank : 'Confirm Password: required.' }
{ confirmPassword : matches('\\w+',?) == true: 'Confirm Password: Only Alpha-Numeric Characters' }
{ city : ? is not blank : 'City: required.' }
{ age : matches('\\d+',?) == true: 'Age: Only Numeric Characters' }
{ age : ? is not blank : 'Age: required.' }
]]></value>
</property>
</bean>

No comments: