| java.lang.Object org.springframework.validation.ValidationUtils
ValidationUtils | abstract public class ValidationUtils (Code) | | Utility class offering convenient methods for invoking a
Validator and for rejecting empty fields.
Checks for an empty field in Validator implementations
can thus become one-liners.
author: Juergen Hoeller author: Dmitriy Kopylenko since: 06.05.2003 See Also: Validator See Also: Errors |
Method Summary | |
public static void | invokeValidator(Validator validator, Object obj, Errors errors) Invoke the given
Validator for the supplied object and
Errors instance. | public static void | rejectIfEmpty(Errors errors, String field, String errorCode) Reject the given field with the given error code if the value is empty.
An 'empty' value in this context means either null or
the empty string "". | public static void | rejectIfEmpty(Errors errors, String field, String errorCode, String defaultMessage) Reject the given field with the given error code and default message
if the value is empty.
An 'empty' value in this context means either null or
the empty string "". | public 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 default message if the value is empty.
An 'empty' value in this context means either null or
the empty string "". | public static void | rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode) Reject the given field with the given error code if the value is empty
or just contains whitespace. | public static void | rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode, String defaultMessage) Reject the given field with the given error code and default message
if the value is empty or just contains whitespace. | public 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 default message if the value is empty or just contains whitespace. |
invokeValidator | public static void invokeValidator(Validator validator, Object obj, Errors errors)(Code) | | Invoke the given
Validator for the supplied object and
Errors instance.
Parameters: validator - the Validator to be invoked (must not be null ) Parameters: obj - the object to bind the parameters to Parameters: errors - the Errors instance that should store the errors (must not be null ) throws: IllegalArgumentException - if either of the Validator or Errors arguments is null ;or if the supplied Validator does not Validator.supports(Class) supportthe validation of the supplied object's type |
rejectIfEmpty | public static void rejectIfEmpty(Errors errors, String field, String errorCode)(Code) | | Reject the given field with the given error code if the value is empty.
An 'empty' value in this context means either null or
the empty string "".
The object whose field is being validated does not need to be passed
in because the
Errors instance can resolve field values by itself
(it will usually hold an internal reference to the target object).
Parameters: errors - the Errors instance to register errors on Parameters: field - the field name to check Parameters: errorCode - the error code, interpretable as message key |
rejectIfEmpty | public static void rejectIfEmpty(Errors errors, String field, String errorCode, String defaultMessage)(Code) | | Reject the given field with the given error code and default message
if the value is empty.
An 'empty' value in this context means either null or
the empty string "".
The object whose field is being validated does not need to be passed
in because the
Errors instance can resolve field values by itself
(it will usually hold an internal reference to the target object).
Parameters: errors - the Errors instance to register errors on Parameters: field - the field name to check Parameters: errorCode - error code, interpretable as message key Parameters: defaultMessage - fallback default message |
rejectIfEmpty | public static void rejectIfEmpty(Errors errors, String field, String errorCode, Object[] errorArgs, String defaultMessage)(Code) | | Reject the given field with the given error code, error arguments
and default message if the value is empty.
An 'empty' value in this context means either null or
the empty string "".
The object whose field is being validated does not need to be passed
in because the
Errors instance can resolve field values by itself
(it will usually hold an internal reference to the target object).
Parameters: errors - the Errors instance to register errors on Parameters: field - the field name to check Parameters: errorCode - the error code, interpretable as message key Parameters: errorArgs - the error arguments, for argument binding via MessageFormat(can be null ) Parameters: defaultMessage - fallback default message |
rejectIfEmptyOrWhitespace | public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode)(Code) | | Reject the given field with the given error code if the value is empty
or just contains whitespace.
An 'empty' value in this context means either null ,
the empty string "", or consisting wholly of whitespace.
The object whose field is being validated does not need to be passed
in because the
Errors instance can resolve field values by itself
(it will usually hold an internal reference to the target object).
Parameters: errors - the Errors instance to register errors on Parameters: field - the field name to check Parameters: errorCode - the error code, interpretable as message key |
rejectIfEmptyOrWhitespace | public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode, String defaultMessage)(Code) | | Reject the given field with the given error code and default message
if the value is empty or just contains whitespace.
An 'empty' value in this context means either null ,
the empty string "", or consisting wholly of whitespace.
The object whose field is being validated does not need to be passed
in because the
Errors instance can resolve field values by itself
(it will usually hold an internal reference to the target object).
Parameters: errors - the Errors instance to register errors on Parameters: field - the field name to check Parameters: errorCode - the error code, interpretable as message key Parameters: defaultMessage - fallback default message |
rejectIfEmptyOrWhitespace | public static void rejectIfEmptyOrWhitespace(Errors errors, String field, String errorCode, Object[] errorArgs, String defaultMessage)(Code) | | Reject the given field with the given error code, error arguments
and default message if the value is empty or just contains whitespace.
An 'empty' value in this context means either null ,
the empty string "", or consisting wholly of whitespace.
The object whose field is being validated does not need to be passed
in because the
Errors instance can resolve field values by itself
(it will usually hold an internal reference to the target object).
Parameters: errors - the Errors instance to register errors on Parameters: field - the field name to check Parameters: errorCode - the error code, interpretable as message key Parameters: errorArgs - the error arguments, for argument binding via MessageFormat(can be null ) Parameters: defaultMessage - fallback default message |
|
|