validation.xml常用验证的配置
1.必须check
<field property="id" depends="required">
<arg position="0" name="required" key="loginForm.id"/>
</field>
2.最大长度和最小长度验证
<field property="password" depends = "required, maxlength, minlength">
<arg0 key = "UserForm.password"/>
<var>
<var-name>maxlength</var-name> --验证名
<var-value>12</var-value>
</var>
<var>
<var-name>minlength</var-name> --验证名
<var-value>6</var-value>
</var>
</field>
3.Email验证
<field property="email" depends="required, email">
<arg0 key="UserForm.email" />
</field>
4.日期验证
<field property="dateV" depends="date">
<var>
<var-name>datePattern</var-name>
<var-value>yyyy/MM/dd</var-value>
</var>
</field>
5.整数范围验证
<field property="score" depends="intRange">
<arg0 key="TestForm.score" />
<arg1 name="intRange" key="${var:min}" resource="false" />
<var>
<var-name>min</var-name>
<var-value>1</var-value>
</var>
<arg2 name="intRange" key="${var:max}" resource="false" />
<var>
<var-name>max</var-name>
<var-value>99999</var-value>
</var>
</field>
6.长度验证(自定义)
例:品番check
<field property="hinban" depends="required,length">
<arg position="0" name="required" key="hinban"/>
<arg position="0" name="length" key="hinban"/>
<arg position="1" name="length" key="${var:length}" resource="false" />
<var>
<var-name>length</var-name>
<var-value>7</var-value>
</var>
</field>
7.日期关联check(开始日,终了日)
<field property="startDate" depends="date">
<var>
<var-name>datePatternStrict</var-name>
<var-value>yyyyMMdd</var-value>
</var>
</field>
<field property="endDate" depends="date,validwhen">
<var>
<var-name>datePatternStrict</var-name>
<var-value>yyyyMMdd</var-value>
</var>
<msg name="validwhen" key="errors.dateFromTo"/>
<arg position="0" name="validwhen" key="label.endDate"/>
<arg position="1" name="validwhen" key="label.fromDate"/>
<var>
<var-name>test</var-name>
<var-value>((*this* == null) or (*this*>=startDate))</var-value>
</var>
</field>