|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.validator.GenericValidator
public class GenericValidator
This class contains basic methods for performing validations.
Field Summary | |
---|---|
private static CreditCardValidator |
creditCardValidator
CreditCardValidator used in wrapper method. |
static java.lang.String |
REGEXP_DELIM
Deprecated. Use ValidatorUtils.REGEXP_DELIMITER instead. |
private static UrlValidator |
urlValidator
UrlValidator used in wrapper method. |
Constructor Summary | |
---|---|
GenericValidator()
|
Method Summary | |
---|---|
protected static java.lang.String |
getDelimittedRegexp(java.lang.String regexp)
Deprecated. use ValidatorUtils.getDelimitedRegExp() instead. |
static boolean |
isBlankOrNull(java.lang.String value)
Checks if the field isn't null and length of the field is greater than zero not including whitespace. |
static boolean |
isByte(java.lang.String value)
Checks if the value can safely be converted to a byte primitive. |
static boolean |
isCreditCard(java.lang.String value)
Checks if the field is a valid credit card number. |
static boolean |
isDate(java.lang.String value,
java.util.Locale locale)
Checks if the field is a valid date. |
static boolean |
isDate(java.lang.String value,
java.lang.String datePattern,
boolean strict)
Checks if the field is a valid date. |
static boolean |
isDouble(java.lang.String value)
Checks if the value can safely be converted to a double primitive. |
static boolean |
isEmail(java.lang.String value)
Checks if a field has a valid e-mail address. |
static boolean |
isFloat(java.lang.String value)
Checks if the value can safely be converted to a float primitive. |
static boolean |
isInRange(byte value,
byte min,
byte max)
Checks if a value is within a range (min & max specified in the vars attribute). |
static boolean |
isInRange(double value,
double min,
double max)
Checks if a value is within a range (min & max specified in the vars attribute). |
static boolean |
isInRange(float value,
float min,
float max)
Checks if a value is within a range (min & max specified in the vars attribute). |
static boolean |
isInRange(int value,
int min,
int max)
Checks if a value is within a range (min & max specified in the vars attribute). |
static boolean |
isInRange(long value,
long min,
long max)
Checks if a value is within a range (min & max specified in the vars attribute). |
static boolean |
isInRange(short value,
short min,
short max)
Checks if a value is within a range (min & max specified in the vars attribute). |
static boolean |
isInt(java.lang.String value)
Checks if the value can safely be converted to a int primitive. |
static boolean |
isLong(java.lang.String value)
Checks if the value can safely be converted to a long primitive. |
static boolean |
isShort(java.lang.String value)
Checks if the value can safely be converted to a short primitive. |
static boolean |
isUrl(java.lang.String value)
Checks if a field is a valid url address. |
static boolean |
matchRegexp(java.lang.String value,
java.lang.String regexp)
Checks if the value matches the regular expression. |
static boolean |
maxLength(java.lang.String value,
int max)
Checks if the value's length is less than or equal to the max. |
static boolean |
minLength(java.lang.String value,
int min)
Checks if the value's length is greater than or equal to the min. |
protected static boolean |
validateCreditCardLuhnCheck(java.lang.String cardNumber)
Deprecated. This functionality has moved to CreditCardValidator. |
protected boolean |
validateCreditCardPrefixCheck(java.lang.String cardNumber)
Deprecated. This functionality has move to CreditCardValidator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String REGEXP_DELIM
private static final UrlValidator urlValidator
private static final CreditCardValidator creditCardValidator
Constructor Detail |
---|
public GenericValidator()
Method Detail |
---|
public static boolean isBlankOrNull(java.lang.String value)
Checks if the field isn't null and length of the field is greater than zero not including whitespace.
value
- The value validation is being performed on.public static boolean matchRegexp(java.lang.String value, java.lang.String regexp)
Checks if the value matches the regular expression.
value
- The value validation is being performed on.regexp
- The regular expression.public static boolean isByte(java.lang.String value)
Checks if the value can safely be converted to a byte primitive.
value
- The value validation is being performed on.public static boolean isShort(java.lang.String value)
Checks if the value can safely be converted to a short primitive.
value
- The value validation is being performed on.public static boolean isInt(java.lang.String value)
Checks if the value can safely be converted to a int primitive.
value
- The value validation is being performed on.public static boolean isLong(java.lang.String value)
Checks if the value can safely be converted to a long primitive.
value
- The value validation is being performed on.public static boolean isFloat(java.lang.String value)
Checks if the value can safely be converted to a float primitive.
value
- The value validation is being performed on.public static boolean isDouble(java.lang.String value)
Checks if the value can safely be converted to a double primitive.
value
- The value validation is being performed on.public static boolean isDate(java.lang.String value, java.util.Locale locale)
Checks if the field is a valid date. The Locale
is
used with java.text.DateFormat
. The setLenient method
is set to false
for all.
value
- The value validation is being performed on.locale
- The locale to use for the date format, defaults to the default
system default if null.public static boolean isDate(java.lang.String value, java.lang.String datePattern, boolean strict)
Checks if the field is a valid date. The pattern is used with
java.text.SimpleDateFormat
. If strict is true, then 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.
The setLenient method is set to false
for all.
value
- The value validation is being performed on.datePattern
- The pattern passed to SimpleDateFormat
.strict
- Whether or not to have an exact match of the datePattern.public static boolean isInRange(byte value, byte min, byte max)
Checks if a value is within a range (min & max specified in the vars attribute).
value
- The value validation is being performed on.min
- The minimum value of the range.max
- The maximum value of the range.public static boolean isInRange(int value, int min, int max)
Checks if a value is within a range (min & max specified in the vars attribute).
value
- The value validation is being performed on.min
- The minimum value of the range.max
- The maximum value of the range.public static boolean isInRange(float value, float min, float max)
Checks if a value is within a range (min & max specified in the vars attribute).
value
- The value validation is being performed on.min
- The minimum value of the range.max
- The maximum value of the range.public static boolean isInRange(short value, short min, short max)
Checks if a value is within a range (min & max specified in the vars attribute).
value
- The value validation is being performed on.min
- The minimum value of the range.max
- The maximum value of the range.public static boolean isInRange(long value, long min, long max)
Checks if a value is within a range (min & max specified in the vars attribute).
value
- The value validation is being performed on.min
- The minimum value of the range.max
- The maximum value of the range.public static boolean isInRange(double value, double min, double max)
Checks if a value is within a range (min & max specified in the vars attribute).
value
- The value validation is being performed on.min
- The minimum value of the range.max
- The maximum value of the range.public static boolean isCreditCard(java.lang.String value)
value
- The value validation is being performed on.protected static boolean validateCreditCardLuhnCheck(java.lang.String cardNumber)
cardNumber
- Credit Card Number.protected boolean validateCreditCardPrefixCheck(java.lang.String cardNumber)
cardNumber
- Credit Card Number.public static boolean isEmail(java.lang.String value)
Checks if a field has a valid e-mail address.
value
- The value validation is being performed on.public static boolean isUrl(java.lang.String value)
Checks if a field is a valid url address.
If you need to modify what is considered valid then consider using the UrlValidator directly.
value
- The value validation is being performed on.public static boolean maxLength(java.lang.String value, int max)
Checks if the value's length is less than or equal to the max.
value
- The value validation is being performed on.max
- The maximum length.public static boolean minLength(java.lang.String value, int min)
Checks if the value's length is greater than or equal to the min.
value
- The value validation is being performed on.min
- The minimum length.protected static java.lang.String getDelimittedRegexp(java.lang.String regexp)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |