net.sf.valjax
Class AbstractValidator

java.lang.Object
  extended by net.sf.valjax.AbstractValidator
All Implemented Interfaces:
Validator
Direct Known Subclasses:
AbstractBlackListValidator

public abstract class AbstractValidator
extends Object
implements Validator

Validator that provides some basic validation patterns to use.

Concrete implementations of this class need to follow the contract stated in the Validator interface.

Author:
Zach Legein
See Also:
Validator

Field Summary
static Pattern NAME_PATTERN_1
          Regular Expression that can be used to validate a name
static Pattern NAME_PATTERN_2
          Regular Expression that can be used to validate a name.
static String PATTERN_ADDRESS
          Regular Expression that can be used to validate an address pattern
static String PATTERN_ALPHA
          Regular Expression that can be used to validate alphabetic patterns
static String PATTERN_ALPHANUMERIC
          Regular Expression that can be used to validate an alpha numeric patterns
static String PATTERN_CURRENCY
          Regular Expression that can be used to validate an currency patterns.
static String PATTERN_DATE
          Regular Expression that can be used to validate date patterns.
static String PATTERN_DIGITS
          Regular Expression that can be used to validate numeric patterns.
static String PATTERN_FAX
          Regular Expression that can be used to validate a phone pattern.
static String PATTERN_MONTH
          Regular Expression that can be used to validate the month.
static String PATTERN_MONTH_YEAR
          Regular Expression that can be used to validate the month and year.
static String PATTERN_NUMBER
          Regular Expression that can be used to validate patterns any number with numeric syntax such as:
static String PATTERN_PHONE
          Regular Expression that can be used to validate a phone pattern with additional syntax, such as extension numbers:
static String PATTERN_YEAR
          Regular Expression that can be used to validate the year using 4 digits.
static String PATTERN_ZIP
          Regular Expression that can be used to validate the zip
 
Constructor Summary
AbstractValidator()
           
 
Method Summary
 Boolean isAddress(String value)
          Uses the address regex pattern to access whether this string value is a match
 Boolean isAlpha(String value)
          Uses the alphabetic regex pattern to access whether this string value is a match
 Boolean isAlphaNumeric(String value)
          Uses the alpha numeric regex pattern to access whether this string value is a match
 Boolean isCurrency(String value)
          Uses the alpha numeric regex pattern to access whether this string value is a match
 Boolean isDate(String value)
          Uses the alpha numeric regex pattern to access whether this string value is a match
 Boolean isDigits(String value)
          Uses the digits regex pattern to access whether this string value is a match
 Boolean isFamilyName(String value)
          Uses the name regex pattern to access whether this string value is a match
 Boolean isFax(String value)
          Uses the fax regex pattern to access whether this string value is a match
 Boolean isGivenName(String value)
          Uses the name regex pattern to access whether this string value is a match
 Boolean isMonth(String value)
          Validate month against format mm
 Boolean isMonthYear(String value)
          Validate month/year against format mm/yyyy
 Boolean isNumber(String value)
          Uses the phone regex pattern to access whether this string value is a match
 Boolean isPhone(String value)
          Uses the phone regex pattern to access whether this string value is a match
 Boolean isYear(String value)
          Uses the year regex pattern to access whether this string value is a match
 Boolean isZip(String value)
          Uses the zip code regex pattern to access whether this string value is a match
 Boolean validateCustom(String value, String pattern)
          Validate a value against your own defined pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.validation.Validator
supports, validate
 

Field Detail

PATTERN_ADDRESS

public static final String PATTERN_ADDRESS
Regular Expression that can be used to validate an address pattern

See Also:
Constant Field Values

PATTERN_ALPHA

public static final String PATTERN_ALPHA
Regular Expression that can be used to validate alphabetic patterns

See Also:
Constant Field Values

PATTERN_ALPHANUMERIC

public static final String PATTERN_ALPHANUMERIC
Regular Expression that can be used to validate an alpha numeric patterns

See Also:
Constant Field Values

PATTERN_CURRENCY

public static final String PATTERN_CURRENCY
Regular Expression that can be used to validate an currency patterns.

For example, $12.45 is a valid pattern.

See Also:
Constant Field Values

PATTERN_DATE

public static final String PATTERN_DATE
Regular Expression that can be used to validate date patterns.

mm/dd/yyyy

See Also:
Constant Field Values

PATTERN_DIGITS

public static final String PATTERN_DIGITS
Regular Expression that can be used to validate numeric patterns.

This is numeric only and doesn't include additiona syntax.

1,233,434.09 is not allowed.

See Also:
Constant Field Values

PATTERN_FAX

public static final String PATTERN_FAX
Regular Expression that can be used to validate a phone pattern.

Pattern is without any additional syntax, this is strictly:

123-123-1233 or 1234567890

See Also:
Constant Field Values

PATTERN_MONTH

public static final String PATTERN_MONTH
Regular Expression that can be used to validate the month.

1-12 or 01-09, 10, 11, 12

See Also:
Constant Field Values

PATTERN_MONTH_YEAR

public static final String PATTERN_MONTH_YEAR
Regular Expression that can be used to validate the month and year.

The month being the first in the pattern.

1-12/2006 or 01-09, 10, 11, 12/2006

See Also:
Constant Field Values

PATTERN_NUMBER

public static final String PATTERN_NUMBER
Regular Expression that can be used to validate patterns any number with numeric syntax such as:

-1,233,434.09

See Also:
Constant Field Values

PATTERN_PHONE

public static final String PATTERN_PHONE
Regular Expression that can be used to validate a phone pattern with additional syntax, such as extension numbers:

123-123-1233x12345 or 1234567890

See Also:
Constant Field Values

PATTERN_YEAR

public static final String PATTERN_YEAR
Regular Expression that can be used to validate the year using 4 digits.

2006

See Also:
Constant Field Values

PATTERN_ZIP

public static final String PATTERN_ZIP
Regular Expression that can be used to validate the zip

Pattern checks for any addtional formats

90404-1234, 90404, 904041234 are allowed

See Also:
Constant Field Values

NAME_PATTERN_2

public static final Pattern NAME_PATTERN_2
Regular Expression that can be used to validate a name.

This may contain charatercs such as, '-', for names like 'Wu-Tang'


NAME_PATTERN_1

public static final Pattern NAME_PATTERN_1
Regular Expression that can be used to validate a name

Constructor Detail

AbstractValidator

public AbstractValidator()
Method Detail

isFamilyName

public Boolean isFamilyName(String value)
Uses the name regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
boolean if value matches patterns or not.
See Also:
NAME_PATTERN_1, NAME_PATTERN_2

isGivenName

public Boolean isGivenName(String value)
Uses the name regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
NAME_PATTERN_1, NAME_PATTERN_2

validateCustom

public Boolean validateCustom(String value,
                              String pattern)
Validate a value against your own defined pattern. Pattern must be written in a valid regular expression.

Parameters:
value - The input to check
pattern - The pattern to match with
Returns:
Whether value matches pattern or not.

isAddress

public Boolean isAddress(String value)
Uses the address regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_ADDRESS

isAlpha

public Boolean isAlpha(String value)
Uses the alphabetic regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_ALPHA

isAlphaNumeric

public Boolean isAlphaNumeric(String value)
Uses the alpha numeric regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_ALPHANUMERIC

isCurrency

public Boolean isCurrency(String value)
Uses the alpha numeric regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_ALPHANUMERIC

isDate

public Boolean isDate(String value)
Uses the alpha numeric regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_ALPHANUMERIC

isDigits

public Boolean isDigits(String value)
Uses the digits regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_DIGITS

isFax

public Boolean isFax(String value)
Uses the fax regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_FAX

isMonth

public Boolean isMonth(String value)
Validate month against format mm

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_MONTH

isMonthYear

public Boolean isMonthYear(String value)
Validate month/year against format mm/yyyy

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_MONTH_YEAR

isNumber

public Boolean isNumber(String value)
Uses the phone regex pattern to access whether this string value is a match

Formats: -#####.### -##,###.###

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_NUMBER

isPhone

public Boolean isPhone(String value)
Uses the phone regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_PHONE

isYear

public Boolean isYear(String value)
Uses the year regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_YEAR

isZip

public Boolean isZip(String value)
Uses the zip code regex pattern to access whether this string value is a match

Parameters:
value - The input to check.
Returns:
Whether value matches pattern or not.
See Also:
PATTERN_ZIP


Copyright © 2007. All Rights Reserved.