You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Van Riper, Mike" <mv...@verisign.com> on 2002/12/12 22:19:22 UTC

Is this a validator DTD bug?

I have a working Struts 1.1-b2 based webapp that uses the validation
framework. My validation.xml file doesn't validate successfully against this
DTD requirement:

  <!ELEMENT field  (msg?, arg0?, arg1?, arg2?, arg3?, var* )>

because when I use both the minlength and maxlength validations on a single
field, I end up with more than one <arg1> element inside the field element
definition like so:

      <field property="zip" depends="minlength,maxlength">
        <arg0 key="prompt.zip"/>
        <arg1 name="minlength" key="${var:minlength}" resource="false"/>
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var>
          <var-name>minlength</var-name>
          <var-value>5</var-value>
        </var>
        <var>
          <var-name>maxlength</var-name>
          <var-value>10</var-value>
        </var>
      </field>

Unless the <arg1> is defined separately for minlength and maxlength
validations, it is not possible to generate the correct validation error
message with the appropriate minlength or maxlength value inserted in the
error message. This is why I believe that the DTD needs to change like so:

  <!ELEMENT field  (msg*, arg0*, arg1*, arg2*, arg3*, var* )>

Otherwise, you are *not* allowed to specify different <msg> or <argx> values
when multiple validation rules are being used. I already posted this on the
struts-user list, but, James Holmes recommended that I post it directly to
the Commons list as the Validator is part of the Commons now.

I realize that in all the examples arg0 is used by convention for the
display name of the field. Even in my webapp, that one could be left as
"arg0+" without causing any problems. However, I don't think the framework
should rely on that convention. So, it would be best to make them all allow
zero or more (*) rather than zero or one (+) occurrences.

If I were setup so that I could easily submit the CVS diff in a bug report,
I would. If it would help, I'd be glad to submit this as a bug report though
without the CVS diff for tracking purposes.

- Mike Van Riper
  mvanriper@verisign.com