Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-13

If two fields are required, and one has a mask, the mask is not checked if the other field is blank

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 10782

    Description

      You have two validated fields in a form, both of which have "required" as a
      validation, and one of which has a mask as a validation. The one which is
      only required is field2, the one with "required,mask" is field1.

      If field2 is blank and field1 has a value that fails the mask, no error is
      generated for field1.

      If field2 is non-blank, field1 is validated properly.

      TEST CASE

      If you put the following in struts-config:

      <form-bean name="testForm"
      type="org.apache.struts.validator.DynaValidatorForm">
      <form-property name="field1" type="java.lang.String"/>
      <form-property name="field2" type="java.lang.String"/>
      </form-bean>

      <action type="<someaction>" name="testForm"
      path="/testAction" input="/testAction.jsp" validate="true"/>

      And the following in your validation.xml
      <form name="testForm">
      <field
      property="field1"
      depends="required,mask">
      <var>
      <var-name>mask</var-name>
      <var-value>^[a-z]</var-value>
      </var>
      </field>
      <field
      property="field2"
      depends="required">
      </field>
      </form>

      And testAction.jsp has:
      <%@ page language="java" %>
      <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
      <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
      <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
      <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="tmp" %>

      <html:errors/>
      <html:form action="/testAction">
      Field 1: <html:text property="field1"/><BR>
      Field 2: <html:text property="field2"/><BR>
      <html:submit/>
      </html:form>

      Attachments

        Activity

          People

            Unassigned Unassigned
            turner@blackbear.com James Turner
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: