<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0//EN" ""> <!-- START SNIPPET: fieldValidatorsExample --> <validators>
对必填校验
<field name="requiredValidatorField"> <field-validator type="required"> <message >必填内容</message> </field-validator> </field>
必填字符串校验
<field name="requiredStringValidatorField"> <field-validator type="requiredstring"> <param name="trim">true</param> <message >字符串必填校验</message> </field-validator> </field>
对int类型的校验
<field name="integerValidatorField"> <field-validator type="int"> <param name="min">1</param> <param name="max">10</param> <message key="validate.integerValidatorField" /> </field-validator> </field>
对日期的校验
<field name="dateValidatorField"> <field-validator type="date"> <param name="min">01/01/1990</param> <param name="max">01/01/2000</param> <message key="validate.dateValidatorField" /> </field-validator> </field>
对email的校验
<field name="emailValidatorField"> <field-validator type="email"> <message key="validate.emailValidatorField" /> </field-validator> </field>
对URL的校验
<field name="urlValidatorField"> <field-validator type="url"> <message key="validate.urlValidatorField" /> </field-validator> </field>
对字符串长度的校验
<field name="stringLengthValidatorField"> <field-validator type="stringlength"> <param name="maxLength">4</param> <param name="minLength">2</param> <param name="trim">true</param> <message key="validate.stringLengthValidatorField" /> </field-validator> </field>
对正则表达式的校验
<field name="regexValidatorField"> <field-validator type="regex"> <param name="expression">.*\.txt</param> <message key="validate.regexValidatorField" /> </field-validator> </field>
对字段表达式的校验
<field name="fieldExpressionValidatorField"> <field-validator type="fieldexpression"> <param name="expression">(fieldExpressionValidatorField == requiredValidatorField)</param> <message key="validate.fieldExpressionValidatorField" /> </field-validator> </field> </validators>
|
阅读(1698) | 评论(0) | 转发(0) |