spring-framework / org.springframework.validation / ValidationUtils

ValidationUtils

abstract class ValidationUtils

Utility class offering convenient methods for invoking a Validator and for rejecting empty fields.

Checks for an empty field in Validator implementations can become one-liners when using #rejectIfEmpty or #rejectIfEmptyOrWhitespace.

Author
Juergen Hoeller

Author
Dmitriy Kopylenko

Since
06.05.2003

See Also
ValidatorErrors

Constructors

<init>

ValidationUtils()

Utility class offering convenient methods for invoking a Validator and for rejecting empty fields.

Checks for an empty field in Validator implementations can become one-liners when using #rejectIfEmpty or #rejectIfEmptyOrWhitespace.

Functions

invokeValidator

open static fun invokeValidator(validator: Validator, obj: Any, errors: Errors): Unit

Invoke the given Validator for the supplied object and Errors instance.

open static fun invokeValidator(validator: Validator, obj: Any, errors: Errors, vararg validationHints: Any): Unit

Invoke the given Validator/SmartValidator for the supplied object and Errors instance.

rejectIfEmpty

open static fun rejectIfEmpty(errors: Errors, field: String, errorCode: String): Unit

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

open static fun rejectIfEmpty(errors: Errors, field: String, errorCode: String, defaultMessage: String): Unit

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

open static fun rejectIfEmpty(errors: Errors, field: String, errorCode: String, errorArgs: Array<Any>): Unit

Reject the given field with the given error code and error arguments 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).

open static fun rejectIfEmpty(errors: Errors, field: String, errorCode: String, errorArgs: Array<Any>, defaultMessage: String): Unit

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

rejectIfEmptyOrWhitespace

open static fun rejectIfEmptyOrWhitespace(errors: Errors, field: String, errorCode: String): Unit

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

open static fun rejectIfEmptyOrWhitespace(errors: Errors, field: String, errorCode: String, defaultMessage: String): Unit

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

open static fun rejectIfEmptyOrWhitespace(errors: Errors, field: String, errorCode: String, errorArgs: Array<Any>): Unit

Reject the given field with the given error code and error arguments 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).

open static fun rejectIfEmptyOrWhitespace(errors: Errors, field: String, errorCode: String, errorArgs: Array<Any>, defaultMessage: String): Unit

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