<field name="username"> <field-validator type="required"> <message>指定检验失败的提示信息</message> </field-validator> </field> </validators>
2。必填字符串检验 <validators> <field name="username"> <field-validator type="requiredstring"> <param name="trim">true</param> <message>指定检验失败的提示信息</message> </field-validator> </field> </validators>
3。整数检验器/浮点检验 <validators> <field name="age"> <field-validator type="int"> <param name="min">1</param> <param name="max">150</param> <message>年纪必须在1到150之间</message> </field-validator> </field> </validators>
4。日期检验 <validators> <field name="birth"> <field-validator type="date"> <param name="min">1900-01-01</param> <param name="max">2050-02-21</param> <message key="birth.range"/> </field-validator> </field> </validators>
5.字段表达式检验器(要求指定字段满足一个逻辑表达式) <validators> <field name="re_pass"> <field-validator type="fieldexpression"> <!--指定逻辑表达式 --> <param name="expression"> (pass eq re_pass)</param> <message>密码必须和确认密码相等</message> </field-validator> </field> </validators>
6.邮件地址校验 <validators> <field name="email"> <field-validator type="email"> <message>你的电子邮件地址必须是一个有效的电邮地址</message> </field-validator> </field> </validators>
7。网址
检验 <validators> <field name="url"> <field-validator type="url"> <message>你的主页地址必须是一个有效的网址</message> </field-validator> </field> </validators>
8.字符串长度检验<validators> <field name="user">
<field-validator type="stringlength"> <param name="minlength">4</param> <param name="maxlength">20</param> <message>你的用户名长度必须在4到20之间</message> </field-validator> </field> </validators>
9.正则表达式检验
<validators> <field name="user"> <field-validator type="regex"> <param name="expression_r"><![CDATA[(\w{4,25})]]></param> <message>您输入的用户名只能是字母和数组,且长度必须在4到25之间</message> </field-validator> </field> </validators>