org.springframework.validation
Class ValidationUtils

java.lang.Object
  extended byorg.springframework.validation.ValidationUtils

public abstract class ValidationUtils
extends Object

This utility class offers convenient methods for invoking a validator and for rejecting an empty field.

Used by BindUtils' bindAndValidate method.

Since:
06.05.2003
Author:
Juergen Hoeller, Dmitriy Kopylenko
See Also:
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, 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, 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

ValidationUtils

public ValidationUtils()
Method Detail

invokeValidator

public static void invokeValidator(Validator validator,
                                   Object object,
                                   Errors errors)
Invoke the given validator for the given object and Errors instance.

Parameters:
validator - validator to be invoked, or null if no validation
object - object to bind the parameters to
errors - Errors instance that should store the errors

rejectIfEmpty

public 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.

Parameters:
errors - Errors instance containing bound fields
field - field name to check
errorCode - to reject with
defaultMessage - to reject with

rejectIfEmpty

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 message if the value is empty.

Parameters:
errors - Errors instance containing bound fields
field - field name to check
errorCode - to reject with
errorArgs - error arguments, for argument binding via MessageFormat (can be null)
defaultMessage - to reject with

rejectIfEmptyOrWhitespace

public 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.

Parameters:
errors - Errors instance containing bound fields
field - field name to check
errorCode - to reject with
defaultMessage - to reject with

rejectIfEmptyOrWhitespace

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 message if the value is empty or just contains whitespace.

Parameters:
errors - Errors instance containing bound fields
field - field name to check
errorCode - to reject with
errorArgs - error arguments, for argument binding via MessageFormat (can be null)
defaultMessage - to reject with


Copyright (C) 2003-2004 The Spring Framework Project.