isString
protected static boolean isString(Object o)
Return true
if the specified object is a String or a null
value.
o
- Object to be tested
- The string value
validateByte
public static Byte validateByte(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field can safely be converted to a byte primitive.
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.
- A Byte if valid, null otherwise.
validateCreditCard
public static Long validateCreditCard(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field is a valid credit card number.
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.
- The credit card as a Long, a null if invalid, blank, or null.
validateDate
public static Date validateDate(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
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.
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.
- A Date if valid, a null if blank or invalid.
validateDouble
public static Double validateDouble(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field can safely be converted to a double primitive.
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.
- A Double if valid, a null otherwise.
validateDoubleRange
public static boolean validateDoubleRange(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in the
vars attribute).
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.
- True if in range, false otherwise.
validateEmail
public static boolean validateEmail(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if a field has a valid e-mail address.
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.
- True if valid, false otherwise.
validateFloat
public static Float validateFloat(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field can safely be converted to a float primitive.
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.
- A Float if valid, a null otherwise.
validateFloatRange
public static boolean validateFloatRange(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in the
vars attribute).
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.
- True if in range, false otherwise.
validateIntRange
public static boolean validateIntRange(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if a fields value is within a range (min & max specified in the
vars attribute).
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.
- True if in range, false otherwise.
validateInteger
public static Integer validateInteger(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field can safely be converted to an int primitive.
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.
- An Integer if valid, a null otherwise.
validateLong
public static Long validateLong(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field can safely be converted to a long primitive.
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.
- A Long if valid, a null otherwise.
validateMask
public static boolean validateMask(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field matches the regular expression in the field's mask attribute.
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.
- true if field matches mask, false otherwise.
validateMaxLength
public static boolean validateMaxLength(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field's length is less than or equal to the maximum value.
A 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 ActionErrors
object to add errors to if any
validation errors occur.request
- Current request object.
- True if stated conditions met.
validateMinLength
public static boolean validateMinLength(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field's length is greater than or equal to the minimum value.
A 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 ActionErrors
object to add errors to if any
validation errors occur.request
- Current request object.
- True if stated conditions met.
validateRange
public static boolean validateRange(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
As of Struts 1.1, replaced by validateIntRange(java.lang.Object,org.apache.commons.validator.ValidatorAction,org.apache.commons.validator.Field,org.apache.struts.action.ActionErrors,javax.servlet.http.HttpServletRequest)
Checks if a fields value is within a range (min & max specified in the
vars attribute).
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.
- True if in range, false otherwise.
validateRequired
public static boolean validateRequired(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field isn't null and length of the field is greater than zero not
including whitespace.
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.
- true if meets stated requirements, false otherwise.
validateRequiredIf
public static boolean validateRequiredIf(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
org.apache.commons.validator.Validator validator,
HttpServletRequest request)
Checks if the field isn't null based on the values of other fields.
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.validator
- The Validator
instance, used to access
other field values.request
- Current request object.
- true if meets stated requirements, false otherwise.
validateShort
public static Short validateShort(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request)
Checks if the field can safely be converted to a short primitive.
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.
- A Short if valid, otherwise null.