org.dbforms.validation
Class DbFormsValidator

java.lang.Object
  extended by org.dbforms.validation.DbFormsValidator
All Implemented Interfaces:
Serializable

public class DbFormsValidator
extends Object
implements Serializable

This class performs validations. The parameters of methods must match the "methodParams" in "validator-rules.xml" file.

Author:
Eric Beaumier
See Also:
Serialized Form

Constructor Summary
DbFormsValidator()
           
 
Method Summary
static boolean validateByte(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field can safely be converted to a byte primitive.
static boolean validateCreditCard(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field is a valid credit card number.
static boolean validateDate(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field is a valid date.
static boolean validateDouble(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field can safely be converted to a double primitive.
static boolean validateEmail(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if a field has a valid e-mail address.
static boolean validateFloat(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field can safely be converted to a float primitive.
static boolean validateInteger(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field can safely be converted to an int primitive.
static boolean validateLong(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field can safely be converted to a long primitive.
static boolean validateMask(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field matches the regular expression in the field's mask attribute.
static boolean validateMaxLength(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field's length is less than or equal to the maximum value.
static boolean validateMinLength(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field's length is greater than or equal to the minimum value.
static boolean validateRange(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if a fields value is within a range (min & max specified in the vars attribute).
static boolean validateRequired(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field isn't null and length of the field is greater than zero not including whitespace.
static boolean validateShort(Object bean, ValidatorAction va, Field field, Vector errors, Locale locale, DbFormsErrors dbFormsErrors)
          Checks if the field can safely be converted to a short primitive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbFormsValidator

public DbFormsValidator()
Method Detail

validateByte

public static boolean validateByte(Object bean,
                                   ValidatorAction va,
                                   Field field,
                                   Vector errors,
                                   Locale locale,
                                   DbFormsErrors dbFormsErrors)

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateCreditCard

public static boolean validateCreditCard(Object bean,
                                         ValidatorAction va,
                                         Field field,
                                         Vector errors,
                                         Locale locale,
                                         DbFormsErrors dbFormsErrors)

Checks if the field is a valid credit card number.

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateDate

public static boolean validateDate(Object bean,
                                   ValidatorAction va,
                                   Field field,
                                   Vector errors,
                                   Locale locale,
                                   DbFormsErrors dbFormsErrors)

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 used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateDouble

public static boolean validateDouble(Object bean,
                                     ValidatorAction va,
                                     Field field,
                                     Vector errors,
                                     Locale locale,
                                     DbFormsErrors dbFormsErrors)

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateEmail

public static boolean validateEmail(Object bean,
                                    ValidatorAction va,
                                    Field field,
                                    Vector errors,
                                    Locale locale,
                                    DbFormsErrors dbFormsErrors)

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

Based on a script by Sandeep V. Tamhankar (stamhankar@hotmail.com), http://javascript.internet.com

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateFloat

public static boolean validateFloat(Object bean,
                                    ValidatorAction va,
                                    Field field,
                                    Vector errors,
                                    Locale locale,
                                    DbFormsErrors dbFormsErrors)

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateInteger

public static boolean validateInteger(Object bean,
                                      ValidatorAction va,
                                      Field field,
                                      Vector errors,
                                      Locale locale,
                                      DbFormsErrors dbFormsErrors)

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateLong

public static boolean validateLong(Object bean,
                                   ValidatorAction va,
                                   Field field,
                                   Vector errors,
                                   Locale locale,
                                   DbFormsErrors dbFormsErrors)

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateMask

public static boolean validateMask(Object bean,
                                   ValidatorAction va,
                                   Field field,
                                   Vector errors,
                                   Locale locale,
                                   DbFormsErrors dbFormsErrors)

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 used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateMaxLength

public static boolean validateMaxLength(Object bean,
                                        ValidatorAction va,
                                        Field field,
                                        Vector errors,
                                        Locale locale,
                                        DbFormsErrors dbFormsErrors)

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 used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateMinLength

public static boolean validateMinLength(Object bean,
                                        ValidatorAction va,
                                        Field field,
                                        Vector errors,
                                        Locale locale,
                                        DbFormsErrors dbFormsErrors)

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 used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateRange

public static boolean validateRange(Object bean,
                                    ValidatorAction va,
                                    Field field,
                                    Vector errors,
                                    Locale locale,
                                    DbFormsErrors dbFormsErrors)

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 used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateRequired

public static boolean validateRequired(Object bean,
                                       ValidatorAction va,
                                       Field field,
                                       Vector errors,
                                       Locale locale,
                                       DbFormsErrors dbFormsErrors)

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 used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to, if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.

validateShort

public static boolean validateShort(Object bean,
                                    ValidatorAction va,
                                    Field field,
                                    Vector errors,
                                    Locale locale,
                                    DbFormsErrors dbFormsErrors)

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

Parameters:
bean - The bean validation is being performed on.
va - The ValidatorAction used to retrieve validator information.
field - The Field object associated with the current field being validated.
errors - The Vector object used by DBForms to add errors to if any validation errors occur.
locale - The Locale object of the Request.
dbFormsErrors - DbForms Error class to retrieve error message in DbForm-Errors.xml format.


Copyright © 2002-2006 DbForms. All Rights Reserved.