public class FieldChecks extends Object implements Serializable
This class contains the default validations that are used in the validator-rules.xml file.
In general passing 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.
Modifier and Type | Field and Description |
---|---|
static String |
FIELD_TEST_EQUAL |
static String |
FIELD_TEST_NOTNULL |
static String |
FIELD_TEST_NULL |
Constructor and Description |
---|
FieldChecks() |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
isString(Object o)
Return
true if the specified object is a String or a
null value. |
static Object |
validateByte(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a byte primitive.
|
static Object |
validateByteLocale(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a byte primitive.
|
static Object |
validateCreditCard(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field is a valid credit card number.
|
static Object |
validateDate(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field is a valid date.
|
static Object |
validateDouble(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a double primitive.
|
static Object |
validateDoubleLocale(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a double primitive.
|
static boolean |
validateDoubleRange(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in
the vars attribute).
|
static boolean |
validateEmail(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if a field has a valid e-mail address.
|
static Object |
validateFloat(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a float primitive.
|
static Object |
validateFloatLocale(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a float primitive.
|
static boolean |
validateFloatRange(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in
the vars attribute).
|
static Object |
validateInteger(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to an int primitive.
|
static Object |
validateIntegerLocale(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to an int primitive.
|
static boolean |
validateIntRange(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in
the vars attribute).
|
static Object |
validateLong(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a long primitive.
|
static Object |
validateLongLocale(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a long primitive.
|
static boolean |
validateLongRange(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in
the vars attribute).
|
static boolean |
validateMask(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field matches the regular expression in the field's mask
attribute.
|
static boolean |
validateMaxLength(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field's length is less than or equal to the maximum
value.
|
static boolean |
validateMinLength(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field's length is greater than or equal to the minimum
value.
|
static boolean |
validateRequired(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field isn't null and length of the field is greater than
zero not including whitespace.
|
static boolean |
validateRequiredIf(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field isn't null based on the values of other fields.
|
static Object |
validateShort(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a short primitive.
|
static Object |
validateShortLocale(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if the field can safely be converted to a short primitive.
|
static boolean |
validateUrl(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
ActionMessages errors,
org.apache.commons.validator.Validator validator,
javax.servlet.http.HttpServletRequest request)
Checks if a field has a valid url.
|
public static final String FIELD_TEST_NULL
public static final String FIELD_TEST_NOTNULL
public static final String FIELD_TEST_EQUAL
public static boolean validateRequired(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateRequiredIf(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateMask(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateByte(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateByteLocale(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateShort(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateShortLocale(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateInteger(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateIntegerLocale(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateLong(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateLongLocale(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateFloat(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateFloatLocale(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateDouble(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateDoubleLocale(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateDate(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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.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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateLongRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateIntRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateDoubleRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateFloatRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static Object validateCreditCard(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateEmail(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateMaxLength(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
Null
will be considered an error.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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateMinLength(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
Null
will be considered an error.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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.public static boolean validateUrl(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, ActionMessages errors, org.apache.commons.validator.Validator validator, javax.servlet.http.HttpServletRequest request)
allow2slashes
can be set to true
or false
to control whether two slashes are allowed -
default is false
(i.e. two slashes are NOT allowed).nofragments
can be set to true
or false
to control whether fragments are allowed -
default is false
(i.e. fragments ARE allowed).allowallschemes
can be set to
true
or false
to control if all schemes are
allowed - default is false
(i.e. all schemes are NOT
allowed).schemes
can be set to a comma delimited list
of valid schemes. This value is ignored if allowallschemes
is set to true
. Default schemes allowed are "http",
"https" and "ftp" if this variable is not specified.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 ActionMessages
object to add errors
to if any validation errors occur.validator
- The Validator
instance, used to access
other field values.request
- Current request object.protected static boolean isString(Object o)
true
if the specified object is a String or a
null
value.o
- Object to be testedCopyright © 2000–2016 Apache Software Foundation. All rights reserved.