Is there a way to setup conditional validation through the validation.xml
file?

I'm currently user the visitor validator method where my core user
validation properties are in a User-validation.xml file. I want to be able
to use this same file for all my user actions (register, add, update) and
just have conditional code which looks a user field to determine validation.

At the moment I'm using a combination of the valididation.xml file and the
validate method in the action.

I know the following doesn't work, but can I have something like this:

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>
<validators>

 <validator type="expression">
    <param name="expression">
      user.action.equals('insert') || user.action.equals('register')</param>
 <!-- only validate these fileds when inserting and registering a user -->
 <field name="user.password">
    <field-validator type="requiredstring">
      <message key="user.password.empty"/>
    </field-validator>
  </field>
  <field name="user.confirmPassword">
    <field-validator type="requiredstring">
      <message key="user.confirmPassword.empty"/>
    </field-validator>
  </field>
 </validator>
<!-- core validated fields -->
    <field name="user.name">
        <field-validator type="requiredstring">
        <message key="user.name.empty">
            resource not found</message>
        </field-validator>
    </field>
    <field name="user.email">
        <field-validator type="requiredstring"
         short-circuit="true">
            <message key="user.email.empty"/>
        </field-validator>
        <field-validator type="email">
            <message key="user.email.invalid"/>
        </field-validator>
    </field>
    <field name="user.phone">
        <field-validator type="stringlength">
        <param name="minLength">10</param>
        <message key="user.phone.length"/>
        </field-validator>
    </field>
    <field name="user.city">
        <field-validator type="requiredstring">
            <message key="user.city.empty"/>
        </field-validator>
    </field>



Z.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to