驗證框架的配置及validation.xml常用的驗證規則
阿新 • • 發佈:2019-01-05
<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="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">