Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: converted to 1.6 markup

This page describes Changes in version 1.2.0 of Commons Validator (see section 1. Changes) and notes on Upgrading from Validator 1.1.4 (see section 2. Upgrading).

...

1. Changes

Wiki Markup*N.B.* Validator version *_1.3.0_* has been released with a number of \[http://jakarta.apache.org/commons/validator/changes-report.html bug fixes\] for version 1.2.0 and it is recommended that users upgrade to version *1.3.0*

Wiki MarkupThe aim of this section is to provide a summary of the changes in *Validator 1.2.0* - for a full list of the changes in this version see the \[http://jakarta.apache.org/commons/validator/changes-report.html Changes Report\].

1.1 Validator Inheritance

...

1.1.1 Explicit Form Inheritance

Wiki MarkupExplicit Form Inheritance is where one \[http://jakarta.apache.org/commons/validator/apidocs/org/apache/commons/validator/Form.html Form\] can inherit from another by specifying the name of the form to inherit using the new *extends* property (which is also an new attribute in the \[http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/validator/trunk/conf/share/validator_1_2_0.dtd?view=markup validator_1_2_0.dtd\]). See \[http://issues.apache.org/bugzilla/show_bug.cgi?id=27870 #27870\].

In the following example nameForm inherits from baseForm, overriding the lastName field...

...

For example, if you have a form named CustomerForm defined in a FormSet for the French language (no country) and also in a FormSet for the Candian French locale then the Candian French version of the Form will inherit from the French one.

Wiki MarkupSee \[http://issues.apache.org/bugzilla/show_bug.cgi?id=30955 Bug 30955\], \[http://issues.apache.org/bugzilla/show_bug.cgi?id=16920 Bug 16920\] and \[http://issues.apache.org/bugzilla/show_bug.cgi?id=37310 Bug 16920\].

N.B. See Section 2. Variables in Resource Bundles which may remove your need to have multiple FormSet's for different locales altogether.

...

One motivation for having different Form Sets was due to the fact that variable values needed to be different for different locales. Validator 1.2.0 has the facility to specify variable values in resource bundles which removes the need for multiple formsets in this instanceunmigrated-wiki-markup

Two new properties have been added to \[http://jakarta.apache.org/commons/validator/apidocs/org/apache/commons/validator/Var.html Variable\] - *resource* and *bundle*. Setting *resource* to *true* (default is _false_) indicates that the variable's value is a _resource key_. Additionally the (optional) *bundle* property can be set to the name of an alternative resource bundle.

In the following example the value of datePattern variable is specified in the validatorVariables bundle under a key of dateOfBirth.pattern.

No Format
    <formset>
        <form name="EmployeeForm">
            <field property="dateOfBirth" depends="date">

                <var resource="true" bundle="validatorVariables">
                    <var-name>datePattern</var-name>
                    <var-value>dateOfBirth.pattern</var-value>
                </var>

            </field>
        </form>
    </formset>

Wiki Markup*N.B.* Validator provides the facility to indicate that a variable's value is in a resource bundle - but it is down to individual configured validators to actually take notice of these properties and retrieve the value from the resource bundle. Struts 1.3 has been upgraded to take advantage this feature and is an example of what custom validators need to do. See the Struts \[http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java?view=markup FieldChecks\] class.

1.3 Arg0-Arg3 Deprecations Removed

...

No Format
        <arg key="first.key"  position="0">
        <arg key="second.key" position="1">

Wiki MarkupPosition is however _optional_ and if omitted, validator will automatically allocate a _position_ value - see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=31194 Bug 31194\] for details.

Additionally, this issue only arises if you upgrade to the new version of the Validator DTD - previous versions of the DTD using arg0-arg3 will continue to work in Validator 1.2.0.

...

A few new validators have been added:

  • Wiki MarkupA new *ISBN Validator* for validating book numbers has been added (see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=31489 #31489\]).unmigrated-wiki-markup
  • New _locale aware_ *byte*, *short*, *integer*, *long*, *float* and *double* validations added (see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=21282 #21282\]). Wiki Markup
  • New *Minimum/Maximum* value validators added (see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=29015 #29015\]). \\

The following validator's issues have been fixed:

...

  • *Email* Validator fixed for \[http://issues.apache.org/bugzilla/show_bug.cgi?id=23990 Bug 23990\], \[http://issues.apache.org/bugzilla/show_bug.cgi?id=29541 Bug 29541\], \[http://issues.apache.org/bugzilla/show_bug.cgi?id=33409 Bug 33409\], \[http://issues.apache.org/bugzilla/show_bug.cgi?id=31644 Bug 31644\]
  • Wiki Markup*URL* Validator fixed for \[http://issues.apache.org/bugzilla/show_bug.cgi?id=30686 Bug 30686\]unmigrated-wiki-markup*
  • Float* Validator fixed for \[http://issues.apache.org/bugzilla/show_bug.cgi?id=32351 Bug 32351\] and \[http://issues.apache.org/bugzilla/show_bug.cgi?id=36878 Bug 36878\]unmigrated-wiki-markup*
  • Double* Validator fixed for \[http://issues.apache.org/bugzilla/show_bug.cgi?id=36878 Bug 36878\] Wiki Markup*
  • Credit Card* Validator fixed for \[http://issues.apache.org/bugzilla/show_bug.cgi?id=35926 Bug 35926\]
  • Date Validator no longer logs the ParseException for an invalid date.

The following JavaScript validator's issues have been fixed:

...

  • The Strategy for locating a form using name/id has changed to correct various issues - see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=35127 Bug 35127\], \[http://issues.apache.org/bugzilla/show_bug.cgi?id=35294 Bug 35294\] and \[http://issues.apache.org/bugzilla/show_bug.cgi?id=31534 Bug 31534\] Wiki Markup*
  • Required* validator fixed for \[http://issues.apache.org/bugzilla/show_bug.cgi?id=15912 Bug 15912\] and \[http://issues.apache.org/bugzilla/show_bug.cgi?id=33047 Bug 33047\]unmigrated-wiki-markup*
  • Date* validator enhanced to support _datePattern_ - see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=22384 Bug 22384\] \\

1.5 Dependency Changes

The following changes to validator's dependencies have occured:

  • Wiki Markup\[http://jakarta.apache.org/commons/beanutils/ Commons BeanUtils\] - upgraded from version 1.6.1 to version 1.7.0 Wiki Markup
  • \[http://jakarta.apache.org/commons/collections/ Commons Collections\] - dependency removed (*see note below*).unmigrated-wiki-markup
  • \[http://jakarta.apache.org/commons/digester/ Commons Digester\] - upgraded from version 1.5 to version 1.6unmigrated-wiki-markup\[http://jakarta.apache.org/commons/digester/
  • Commons Logging\] - upgraded from version 1.0.3 to version 1.0.4 \\

Wiki Markup*N.B.* \[http://jakarta.apache.org/commons/beanutils/ Commons BeanUtils\] 1.7.0 removed its dependency on \[http://jakarta.apache.org/commons/collections/ Commons Collections\] by including the few required Collections classes in its distribution. This is why Validator 1.2.0 no longer has a dependency on Collections - Collection's classes used by Validator are in [BeanUtils] 1.7.0.

...

2. Upgrading

This section describes upgrading from validator 1.1.4.

...

Obvious, but don't forget to deploy the new Validator 1.2.0 jar and also upgrade to new versions of dependency jars for BeanUtils, Digester and Logging (see section 1.5 above).

2.2 New DTD version

Wiki MarkupThere is a new version of the validator DTD: \[http: //svn.apache.org/viewcvs.cgi/jakarta/commons/proper/validator/trunk/conf/share/validator_1_2_0.dtd?view=markup validator_1_2_0.dtd\]. However the previous version of the DTD (\[http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/validator/trunk/conf/share/validator_1_1_3.dtd?view=markup validator_1_1_3.dtd\]) will continue to work and there is no requirement to upgrade.unmigrated-wiki-markup

Upgrading your system to use \[http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/validator/trunk/conf/share/validator_1_2_0.dtd?view=markup validator_1_2_0.dtd\] has the following consequences:

  • You will be able to use the new features that depend on the attributes that have been added to the DTD.
  • If your validation.xml files uses the ar0-arg3 elements - these will need to be replaced with "arg" - see the section 1.3 Arg0-Arg3 Deprecations Removed above.

...


NOT Upgrading your system to use \[http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/validator/trunk/conf/share/validator_1_2_0.dtd?view=markup validator_1_2_0.dtd\] has the following consequences:

  • You won't be able to use (some of) the new features which depend on new elements in the DTD.

...

  • Validator 1.2.0 can be deployed with Struts 1.2.x to take advantage of the new features(except one, see below).
  • Wiki MarkupIn Struts 1.2.7 Javascript validation doesn't work in XHTML mode (see \[http://issues.apache.org/bugzilla/show_bug.cgi?id=35127 Bug 35127\]) - resolving this bug requires upgrading to Struts 1.2.8 (hopefully soon to be released) and Validator 1.2.0
  • The Variables in Resource Bundles feature described in section 1.2 above does not work in Struts 1.2.x - this requires Struts 1.3

...