Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.util
Class StrutsValidator

    java.lang.Object
      |
      +--org.apache.struts.util.StrutsValidator

All Implemented Interfaces:
  java.io.Serializable

Deprecated. As of Struts 1.1, replaced by `FieldChecks`

public class StrutsValidator
extends java.lang.Object
implements java.io.Serializable

This class contains the default validations that are used in the validator-rules.xml file.

In general passin in a null or blank will return a null Object or a false boolean. However, nulls and blanks do not result in an error being added to the errors.

Since:
  Struts 1.1
Author:
  David Winterfeldt, James Turner
See Also:
  Serialized Form

Field Summary
`static java.lang.String` | `FIELD_TEST_EQUAL` Deprecated.
`static java.lang.String` | `FIELD_TEST_NOTNULL` Deprecated.
`static java.lang.String` | `FIELD_TEST_NULL` Deprecated. Commons Logging instance.

Constructor Summary
`StrutsValidator()` Deprecated.

Method Summary
`static java.lang.Byte` | `validateByte(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateByte(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static java.lang.Long` | `validateCreditCard(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateCreditCard(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)` Translated to Java by Ted Husted (husted@apache.org ). Reference Sean M. Burke's script at http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
`static java.util.Date` | `validateDate(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateDate(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static java.lang.Double` | `validateDouble(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateDouble(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static boolean` | `validateEmail(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateEmail(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)` Based on a script by Sandeep V. Tamhankar (stamhankar@hotmail.com), http://javascript.internet.com
`static java.lang.Float` | `validateFloat(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateFloat(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static java.lang.Integer` | `validateInteger(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateInteger(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static java.lang.Long` | `validateLong(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateLong(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static boolean` | `validateMask(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateMask(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static boolean` | `validateMaxLength(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateMaxLength(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static boolean` | `validateMinLength(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateMinLength(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static boolean` | `validateRange(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateIntRange(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static boolean` | `validateRequired(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateRequired(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`
`static java.lang.Short` | `validateShort(java.lang.Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionErrors errors, javax.servlet.http.HttpServletRequest request)` Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateShort(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FIELD_TEST_NULL

    public static final java.lang.String FIELD_TEST_NULL

  Deprecated.
  Commons Logging instance.

  See Also:
    Constant Field Values

### FIELD_TEST_NOTNULL

    public static final java.lang.String FIELD_TEST_NOTNULL

  Deprecated.
  See Also:
    Constant Field Values

### FIELD_TEST_EQUAL

    public static final java.lang.String FIELD_TEST_EQUAL

  Deprecated.
  See Also:
    Constant Field Values

Constructor Detail

### StrutsValidator

    public StrutsValidator()

  Deprecated.

Method Detail

### validateRequired

    public static boolean validateRequired(java.lang.Object bean,
                                           org.apache.commons.validator.ValidatorAction va,
                                           org.apache.commons.validator.Field field,
                                           ActionErrors errors,
                                           javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateRequired(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field isn't null and length of the field is greater than zero not including whitespace.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    True if meets stated requirements, False otherwise

### validateMask

    public static boolean validateMask(java.lang.Object bean,
                                       org.apache.commons.validator.ValidatorAction va,
                                       org.apache.commons.validator.Field field,
                                       ActionErrors errors,
                                       javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateMask(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field matches the regular expression in the field's mask attribute.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    True if field matches mask, false otherwise.

### validateByte

    public static java.lang.Byte validateByte(java.lang.Object bean,
                                              org.apache.commons.validator.ValidatorAction va,
                                              org.apache.commons.validator.Field field,
                                              ActionErrors errors,
                                              javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateByte(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field can safely be converted to a byte primitive.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    A Byte if valid, a null otherwise.

### validateShort

    public static java.lang.Short validateShort(java.lang.Object bean,
                                                org.apache.commons.validator.ValidatorAction va,
                                                org.apache.commons.validator.Field field,
                                                ActionErrors errors,
                                                javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateShort(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field can safely be converted to a short primitive.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    A Short if valid, otherwise a null.

### validateInteger

    public static java.lang.Integer validateInteger(java.lang.Object bean,
                                                    org.apache.commons.validator.ValidatorAction va,
                                                    org.apache.commons.validator.Field field,
                                                    ActionErrors errors,
                                                    javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateInteger(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field can safely be converted to an int primitive.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    An Integer if valid, a null otherwise.

### validateLong

    public static java.lang.Long validateLong(java.lang.Object bean,
                                              org.apache.commons.validator.ValidatorAction va,
                                              org.apache.commons.validator.Field field,
                                              ActionErrors errors,
                                              javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateLong(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field can safely be converted to a long primitive.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    A Long if valid, a null otherwise.

### validateFloat

    public static java.lang.Float validateFloat(java.lang.Object bean,
                                                org.apache.commons.validator.ValidatorAction va,
                                                org.apache.commons.validator.Field field,
                                                ActionErrors errors,
                                                javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateFloat(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field can safely be converted to a float primitive.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    A Float if valid, a null otherwise.

### validateDouble

    public static java.lang.Double validateDouble(java.lang.Object bean,
                                                  org.apache.commons.validator.ValidatorAction va,
                                                  org.apache.commons.validator.Field field,
                                                  ActionErrors errors,
                                                  javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateDouble(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field can safely be converted to a double primitive.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    A Double if valid, a null otherwise.

### validateDate

    public static java.util.Date validateDate(java.lang.Object bean,
                                              org.apache.commons.validator.ValidatorAction va,
                                              org.apache.commons.validator.Field field,
                                              ActionErrors errors,
                                              javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateDate(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field is a valid date. If the field has a datePattern variable, that will be used to format `java.text.SimpleDateFormat`. If the field has a datePatternStrict variable, that will be used to format `java.text.SimpleDateFormat` and the length will be checked so '2/12/1999' will not pass validation with the format 'MM/dd/yyyy' because the month isn't two digits. If no datePattern variable is specified, then the field gets the DateFormat.SHORT format for the locale. The setLenient method is set to `false` for all variations.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    A Date if valid, a null if blank or invalid.

### validateRange

    public static boolean validateRange(java.lang.Object bean,
                                        org.apache.commons.validator.ValidatorAction va,
                                        org.apache.commons.validator.Field field,
                                        ActionErrors errors,
                                        javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateIntRange(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if a fields value is within a range (min & max specified in the vars attribute).

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    True if in range, false otherwise.

### validateCreditCard

    public static java.lang.Long validateCreditCard(java.lang.Object bean,
                                                    org.apache.commons.validator.ValidatorAction va,
                                                    org.apache.commons.validator.Field field,
                                                    ActionErrors errors,
                                                    javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateCreditCard(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)` Translated to Java by Ted Husted (husted@apache.org ).
  Reference Sean M. Burke's script at http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl

  Checks if the field is a valid credit card number.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    The credit card as a Long, a null if invalid, blank, or null.

### validateEmail

    public static boolean validateEmail(java.lang.Object bean,
                                        org.apache.commons.validator.ValidatorAction va,
                                        org.apache.commons.validator.Field field,
                                        ActionErrors errors,
                                        javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateEmail(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)` Based on a script by Sandeep V. Tamhankar (stamhankar@hotmail.com), http://javascript.internet.com

  Checks if a field has a valid e-mail address.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    True if valid, false otherwise.

### validateMaxLength

    public static boolean validateMaxLength(java.lang.Object bean,
                                            org.apache.commons.validator.ValidatorAction va,
                                            org.apache.commons.validator.Field field,
                                            ActionErrors errors,
                                            javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateMaxLength(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field's length is less than or equal to the maximum value. A `Null` will be considered an error.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    True if stated conditions met.

### validateMinLength

    public static boolean validateMinLength(java.lang.Object bean,
                                            org.apache.commons.validator.ValidatorAction va,
                                            org.apache.commons.validator.Field field,
                                            ActionErrors errors,
                                            javax.servlet.http.HttpServletRequest request)

  Deprecated. As of Struts 1.1, replaced by `FieldChecks.validateMinLength(Object,ValidatorAction,Field,ActionErrors,HttpServletRequest)`

  Checks if the field's length is greater than or equal to the minimum value. A `Null` will be considered an error.

  Parameters:
    `bean` - The bean validation is being performed on.
    `va` - The `ValidatorAction` that is currently being performed.
    `field` - The `Field` object associated with the current field being validated.
    `errors` - The `ActionErrors` object to add errors to if any validation errors occur.
    `request` - Current request object.
  Returns:
    True if stated conditions met.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 - Apache Software Foundation