|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springmodules.validation.commons.FieldChecks
public class FieldChecks
This class contains the default validations that are used in the validator-rules.xml file.
In general passing in anull
or blank will return a null
Object
or a
false
boolean
. However, null
s and blanks do not result in an error being added to
the Error
s.
Field Summary | |
---|---|
static String |
FIELD_TEST_EQUAL
|
static String |
FIELD_TEST_NOTNULL
|
static String |
FIELD_TEST_NULL
|
Constructor Summary | |
---|---|
FieldChecks()
|
Method Summary | |
---|---|
protected static String |
extractValue(Object bean,
org.apache.commons.validator.Field field)
Extracts the value of the given bean. |
static void |
rejectValue(Errors errors,
org.apache.commons.validator.Field field,
org.apache.commons.validator.ValidatorAction va)
Convinience method to perform the work of rejecting a field's value. |
static Byte |
validateByte(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
Checks if the field can safely be converted to a byte primitive. |
static Long |
validateCreditCard(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
Checks if the field is a valid credit card number. |
static Date |
validateDate(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
Checks if the field is a valid date. |
static Double |
validateDouble(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
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,
Errors errors)
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,
Errors errors)
Checks if a field has a valid e-mail address. |
static Float |
validateFloat(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
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,
Errors errors)
Checks if a fields value is within a range (min & max specified in the vars attribute). |
static Integer |
validateInteger(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
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,
Errors errors)
Checks if a fields value is within a range (min & max specified in the vars attribute). |
static Long |
validateLong(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
Checks if the field can safely be converted to a long primitive. |
static boolean |
validateMask(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
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,
Errors errors)
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,
Errors errors)
Checks if the field's length is greater than or equal to the minimum value. |
static boolean |
validateRange(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
Deprecated. As of Struts 1.1, replaced by #validateIntRange(java.lang.Object,
org.apache.validator.validator.ValidatorAction,
org.apache.validator.validator.Field,
org.apache.struts.action.Errors,
javax.servlet.http.HttpServletRequest) |
static boolean |
validateRequired(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
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,
Errors errors,
org.apache.commons.validator.Validator validator)
Checks if the field isn't null based on the values of other fields. |
static Short |
validateShort(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors)
Checks if the field can safely be converted to a short primitive. |
static boolean |
validateValidWhen(Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
Errors errors,
org.apache.commons.validator.Validator validator)
Checks if the field matches the boolean expression specified in test parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FIELD_TEST_NULL
public static final String FIELD_TEST_NOTNULL
public static final String FIELD_TEST_EQUAL
Constructor Detail |
---|
public FieldChecks()
Method Detail |
---|
public static boolean validateRequired(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any validation errors occur.
true
if meets stated requirements, false
otherwise.public static boolean validateRequiredIf(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors, org.apache.commons.validator.Validator validator)
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 Errors
object to add errors to if any
validation errors occur.validator
- The Validator
instance, used to access other
field values.
-param request
Current request object.
public static boolean validateMask(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Byte validateByte(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Short validateShort(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Integer validateInteger(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Long validateLong(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Float validateFloat(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Double validateDouble(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Date validateDate(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
#validateIntRange(java.lang.Object,
org.apache.validator.validator.ValidatorAction,
org.apache.validator.validator.Field,
org.apache.struts.action.Errors,
javax.servlet.http.HttpServletRequest)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateIntRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
true
if in range, false
otherwise.public static boolean validateDoubleRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateFloatRange(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static Long validateCreditCard(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateEmail(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateMaxLength(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateMinLength(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors)
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 Errors
object to add errors to if any
validation errors occur.
-param request
Current request object.
public static boolean validateValidWhen(Object bean, org.apache.commons.validator.ValidatorAction va, org.apache.commons.validator.Field field, Errors errors, org.apache.commons.validator.Validator validator)
test
parameter.
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 Errors
object to add errors to if any
validation errors occur.
true
if meets stated requirements,
false
otherwise.protected static String extractValue(Object bean, org.apache.commons.validator.Field field)
null
, the returned value is also null
.
If the bean is a String
then the bean itself is returned. In all other cases, the ValidatorUtils
class is used to extract the bean value using the Field
object supplied.
ValidatorUtils.getValueAsString(Object, String)
public static void rejectValue(Errors errors, org.apache.commons.validator.Field field, org.apache.commons.validator.ValidatorAction va)
errors
- the errorsfield
- the field that was rejectedva
- the validator action
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |