|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.validation.ValidationUtils
public abstract class ValidationUtils
This utility class offers convenient methods for invoking a Validator and for rejecting empty fields. Empty field checks in Validator implementations can become one-liners.
Used by BindUtils' bindAndValidate
method.
Validator
,
Errors
,
BindUtils.bindAndValidate(javax.servlet.ServletRequest, java.lang.Object, java.lang.String, org.springframework.validation.Validator)
Constructor Summary | |
---|---|
ValidationUtils()
|
Method Summary | |
---|---|
static void |
invokeValidator(Validator validator,
Object object,
Errors errors)
Invoke the given validator for the given object and Errors instance. |
static void |
rejectIfEmpty(Errors errors,
String field,
String errorCode)
Reject the given field with the given error code and message if the value is empty. |
static void |
rejectIfEmpty(Errors errors,
String field,
String errorCode,
Object[] errorArgs,
String defaultMessage)
Reject the given field with the given error code, error arguments and message if the value is empty. |
static void |
rejectIfEmpty(Errors errors,
String field,
String errorCode,
String defaultMessage)
Reject the given field with the given error code and message if the value is empty. |
static void |
rejectIfEmptyOrWhitespace(Errors errors,
String field,
String errorCode)
Reject the given field with the given error code and message if the value is empty or just contains whitespace. |
static void |
rejectIfEmptyOrWhitespace(Errors errors,
String field,
String errorCode,
Object[] errorArgs,
String defaultMessage)
Reject the given field with the given error code, error arguments and message if the value is empty or just contains whitespace. |
static void |
rejectIfEmptyOrWhitespace(Errors errors,
String field,
String errorCode,
String defaultMessage)
Reject the given field with the given error code and message if the value is empty or just contains whitespace. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ValidationUtils()
Method Detail |
---|
public static void invokeValidator(Validator validator, Object object, Errors errors)
validator
- validator to be invoked, or null if no validationobject
- object to bind the parameters toerrors
- Errors instance that should store the errorspublic static void rejectIfEmpty(Errors errors, String field, String errorCode)
The object to validate does not have to be passed in, as the Errors instance allows to check field values (it will usually hold an internal reference to the target object).
errors
- Errors instance to register errors onfield
- the field name to checkerrorCode
- error code, interpretable as message keypublic static void rejectIfEmpty(Errors errors, String field, String errorCode, String defaultMessage)
The object to validate does not have to be passed in, as the Errors instance allows to check field values (it will usually hold an internal reference to the target object).
errors
- Errors instance to register errors onfield
- the field name to checkerrorCode
- error code, interpretable as message keydefaultMessage
- fallback default messagepublic static void rejectIfEmpty(Errors errors, String field, String errorCode, Object[] errorArgs, String defaultMessage)
The object to validate does not have to be passed in, as the Errors instance allows to check field values (it will usually hold an internal reference to the target object).
errors
- Errors instance to register errors onfield
- the field name to checkerrorCode
- error code, interpretable as message keyerrorArgs
- error arguments, for argument binding via MessageFormat
(can be null)defaultMessage
- fallback default messagepublic static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode)
The object to validate does not have to be passed in, as the Errors instance allows to check field values (it will usually hold an internal reference to the target object).
errors
- Errors instance to register errors onfield
- the field name to checkerrorCode
- error code, interpretable as message keypublic static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode, String defaultMessage)
The object to validate does not have to be passed in, as the Errors instance allows to check field values (it will usually hold an internal reference to the target object).
errors
- Errors instance to register errors onfield
- the field name to checkerrorCode
- error code, interpretable as message keydefaultMessage
- fallback default messagepublic static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode, Object[] errorArgs, String defaultMessage)
The object to validate does not have to be passed in, as the Errors instance allows to check field values (it will usually hold an internal reference to the target object).
errors
- Errors instance to register errors onfield
- the field name to checkerrorCode
- error code, interpretable as message keyerrorArgs
- error arguments, for argument binding via MessageFormat
(can be null)defaultMessage
- fallback default message
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |