Struts Validator
 Validation Framework for Struts
Home
Installation
Overview
JSP Tags
Javadoc
To Do List
Revision Info
Downloads
Contact Information

Revision Info

Update 1/14/2002
  • Upgraded to use Commons Validator (http://jakarta.apache.org/commons).
  • Packages changed to fall under org.apache.struts.validator.
  • Documentation updated
  • Custom JSP Tags except for JavascriptValidatorTag have been removed.
  • GenericAction class and JDBC example have been removed.
  • Added config-rules parameter to the ValidatorServlet so validation rules could be stored in a separate xml file. The config parameter file can still contain rules. The file specified by config-rules will be loaded first so the file specified by config can define or override any validator elements necessary.
Update 10/18/2001 (using Struts 10/18/2001 source)
  • The last change that added indexed properties broke all locales except for the default locale. The Field wasn't processed yet when the locale field genration occurred and was returning a null key value.
  • Added a check so JavascriptValidatorTag won't generate indexed properties.
  • Changed Javascript to validate for a type of 'select-one' instead of 'select'. Javascript returns 'select-one' for a field's type value.
  • Added min and max functions.
  • Removed code from Validator retrieving the value to be validated. It wasn't being used and this way as long as you specify a unique name for a field a custom validator that isn't specifically tied to a field won't generate an error in the logs.
  • The web apps were changed to use html:messages and logic:messagesPresent for error messages.
Update 9/25/2001 (using Struts 9/25/2001 source)
  • Upgraded to commons packages for Bean Utils, Collections, and the Digester.
  • Modified build.xml and build.properties.
  • A jsFunctionName attribute was added to the validator element so you could specify a function/object name to be used when the JavascriptValidatorTag generates the dynamic JavaScript. Netscape seemed to assume validators like float were keywords. If another function/object name was used, everything worked fine in Netscape.
  • Basic indexed validation capablities have been added for use with 'indexed="true"' capablilities of the html form tags.

    I haven't had time to add this to an example, but below is a sample usage.

        <logic:iterate id="listElement" name="registrationForm" property="listElementList" indexId="index">
           <html:textarea indexed="true" name="listElement" property="value" cols="60" rows="8"/><br>
        </logic:iterate>

        <field property="value"
              indexedProperty="listElement"
              indexedListProperty="listElementList"
              depends="required">
           <arg0 key="registrationForm.paragraph.displayname"/>
        </field>
Update 7/2/2001 (using Struts 1.0)
  • Only the fields that are different from the default FormSet need to be added to the FormSet of another locale. A complete list of fields will be generated for each locale based on the default FormSet. As the complete list of fields is generated, the list will be built with the fields that are the closest match for the locale of the FormSet. If the language is 'fr' and country is 'CA', then if the field doesn't exist under 'fr_CA' it will be looked for under 'fr' and then it will use the default locale. If you are using a variable, replacement won't occur until after the complete field list for each locale is generated. This needs more testing, but seems functional.
  • Changed all StrutsValidator methods (except validateRequired) to only perform validation if there is something other than a space entered. This way if you want to removed the depends="required" from a validator, the user will receive an error message once once something is entered in a field along with any fields that are still required.
  • The required JavaScript function now also checks for select and radio fields.
Update 6/30/2001 (using Struts 1.0)
  • Fixed a bug in the behavior of the mask validator (caused by the source changes from 6/24/2001).
  • Removed a check for 'required' from the Valiator so it wouldn't automatically skip the rest of the validations if the field was required, but not filled in. The behavior should rely on the dependencies of a validator instead.
  • The JavaScript for the pluggable validators is now an element. So the JavaScript can now be put in CDATA so XML sensitive characters do not need to be escaped.
  • The Var for the pluggable validators is now an element with subelements. So the var-value can now be put in CDATA so XML sensitive characters do not need to be escaped.
Update 6/24/2001 (using Struts 1.0)
  • Restructured the source so validations can be run in other frameworks than Struts. You can specify the method signature using the methodParams attribute of the validator element and putting in a comma delimited list of class names. Then a Map is populated using the class name as the key and the value is the instance of the class to be used during validation. Everything should be transparent to users of a recent release.
  • ValidationResources was renamed to ValidatorResources for consistent naming.
  • Added two simple unit tests using Cactus.
  • Added JavaScript validations for byte, short, int, and float.
Update 6/22/2001 (using Struts 1.0)
  • Added dynamicJavascript and staticJavascript attributes to the JavascriptValidatorTag so you can create just the dynamic JavaScript for page validation and reference another page for the static JavaScript to take advantage of browser caching (to see a working example look at the jsType.jsp in the main example webapp).
Update 6/20/2001 (using Struts 1.0)
  • Added the beginnings of a basic JavaScript date validation. Currently works if a datePatternStrict variable is created. It does an exact match like the server side method if datePatternStrict is specified. It currently only can handle the following order of fields (month, day, year), (day, month, year), and (year, month, day). Only a two digit month, two digit day, and a four digit year. Each can be separated by a delimeter or not. The following would be valid MM/dd/yyyy, MM-dd-yyyy, dd.MM.yyyy, yyyyMMdd, etc.
  • Fixed i18n bug generating JavaScript error messages.
Update 6/17/2001 (using Struts 1.0)
  • A bCancel variable was added to the JavascriptValidatorTag code generation so the onclick attribute of the html:cancel tag can be assigned "bCancel=true;" so the JavaScript validation isn't performed and the onclick attribute of a html:submit tag can be assigned "bCancel=false;".
  • Added a client and server side credit card validation donated by Ted Husted and based a script Sean M. Burke wrote.
  • Added a client and server side email validation based on a script by Sandeep V. Tamhankar.
  • The date validation has been changed to use DateFormat and SimpleDateFormat and is configurable with the "datePattern" and "datePatternStrict" variables.
  • All JavaScript methods now set the focus to the first field that failed validation.
Update 6/11/2001 (using Struts 1.0 beta 3 build)
  • The Var class has had a JavaScript Type field added to it to control the type of the variable when the JavaScript is auto-generated. The types are int, string, and regexp. If the jsType attribute is not specified in the XML file it will default to a String and I've made it still recognize the 'mask' variable that the mask pluggable validator uses so jsType="regexp" does not explicitly have to be added for now. In Field the getVar method returns a Var and getVarValue returns the value in case anyone has written their own validation routine using variables.
  • Changed load-on-startup in the web.xml to for the ActionServlet to 1 in both examples. It causes an error in the Orion server 1.5.2 if two servlets have the same load-on-startup value.
  • The ValidatorServlet's debug level is set on ValidationResources to control whether it prints debug info to standard out.
Update 5/10/2001 (using Struts 4/24/2001 build)
  • Javascript objects used for validation are now adding the Field's var elements to this object so it is possible to do basic client side validations with variables. All of this needs more testing, but everything seems functional. Currently all vars are being created as Strings except if it sees that the var name is 'mask', but I will add a jsType to the var element so you can specify if it is a int, String, or RegExp in Javascript.
  • Created Javascript method for the range pluggable validator. It currently isn't used in an example, but was tested.
Update 5/7/2001 (using Struts 4/24/2001 build)
  • Major change in the way message resource arguments are handled. The new way is much more flexible than just automatically passing in the displayname attribute. The Field's displayname attribute has been removed. The arg element should be used instead.
  • The attributes delim, displayname, mask, maskmsg, and vars were removed from the Field element. The msg, arg0-arg4, and vars elements should be used instead. Mask has been changed to use the var element.
  • Added the build scripts for Cactus Unit Testing and a simple test.
Last Updated 4/24/2001 (using Struts 4/24/2001 build)
  • Fixed server side validation to handle nested and indexed properties.
  • Fixed client side Javascript validation to handle nested and indexed properties. (The auto-generated Javascript couldn't handle periods and brackets in the property names.)
  • Modified the basic example WAR to use nested properties for city and state and the zip uses a nested property with an array.
Update 4/20/2001 (using Struts 3/22/2001 build)
  • Added a method attribute to the JavascriptValidatorTag so you can specify a method name other than the one generated from the form name. (ex: If the form name is com.wintecinc.Registration, this will create an invalid Javascript method (validateCom.wintecinc.Registration)).
Update 4/10/2001 (using Struts 3/22/2001 build)
  • Made a var element to replace the vars attribute in a field. The associated vars methods and variables have been deprecated and will be removed in the future. Once var elements are used the vars attribute will no longer be parsed.
  • Updated class files to all have the Apache License at the top.
Update 3/22/2001 (using Struts 3/22/2001 build)
  • Added a message tag and all equivalent classes that the errors tag has. It is for general messages upon completions of actions.
  • Added a GenericAction and GenericForm to handle similiar form actions for forms that save and retrieve data to persistent storage, such as a database.
  • Added a web app that uses JDBC to save and retrieve the form data. The sql script for the table is in the sql directory. The data source for the connection pool defined at the top of the struts-config.xml will need to be modified to use the database you create the table in.
  • Reorganized directory structures of the source code, JSPs, and configuration files to support multiple web applications. Modified Ant build script to handle the changes.
Update 3/19/2001 (using Struts 3/6/2001 build)
  • Finished errors tag that iterates through the error messages. It should have all the functionality of the Struts Error Tag now.
  • Created an errors exists tag. If there are error messages, it will display whatever is in it's body.
Update 3/18/2001 (using Struts 3/6/2001 build)
  • Added javascript to the pluggable validators.
  • Enhanced JavascriptValidatorTag to use the javascript method defined in the pluggable validator.
  • Created errors tag that iterates through the error messages so HTML formatting could be removed from the message resource error messages.
Update 3/15/2001 (using Struts 3/6/2001 build)
  • Caching of objects for pluggable validators. As a ValidatorAction is added to the ValidationResources, an instance of the class is stored in the ValidatorAction.
  • Set validate="true" in struts-config.xml for registration form and type form to simplify example.
Update 3/7/2001 (using Struts 3/6/2001 build)
  • Made JavascriptValidatorTag generate Javascript that also checks password fields.
  • Location of validation.xml is now configurable in the web.xml file.
  • Added a range example using the field's vars attribute for min and max to the type form's integer field in the example web app.
  • Finished basic comments for javadoc.
Update 3/5/2001 (using Struts 2/16/2001 build)
  • Fixed a problem loading the validation.xml file in Tomcat 4.0.
  • Changed the interface for the pluggable validator. This should be close to the final interface. I'm now passing in the request and application context instead of passing in the scope objects you might want.
Update 3/2/2001 (using Struts 2/16/2001 build)
  • Change package names to start with com.wintecinc from org.apache (was originally packaged this way as part of a contribution to struts).
  • Added a vars attribute to Field to store data for a pluggable validator.
Update 3/1/2001 (using Struts 2/16/2001 build)
  • Changed interface to dynamically called validation methods to pass the entire form object so someone can compare the current field to others.
  • Worked on sort for dependencies. It works for basic dependencies, but it needs work.
  • Required method removed from field class (not in use).
Update 2/25/2001
  • Global and FormSet/Locale Constants
  • Pluggable validators (needs more testing)
Update 2/22/2001 (Version 0.5)
    Version 0.5 has a couple of bug fixes compared to the actual 2/22 release.

  • Full Locale Support
Update 2/14/2001
  • Multiple Page Form Support Added
  • Client Side Javascript Validation Tag