spring-framework / org.springframework.validation / ValidationUtils / rejectIfEmptyOrWhitespace

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

Parameters

errors - the Errors instance to register errors on

field - the field name to check

errorCode - the error code, interpretable as message key

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

Parameters

errors - the Errors instance to register errors on

field - the field name to check

errorCode - the error code, interpretable as message key

defaultMessage - fallback default message

open static fun rejectIfEmptyOrWhitespace(errors: Errors, field: String, errorCode: String, @Nullable 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).

Parameters

errors - the Errors instance to register errors on

field - the field name to check

errorCode - the error code, interpretable as message key

errorArgs - the error arguments, for argument binding via MessageFormat (can be null)

open static fun rejectIfEmptyOrWhitespace(errors: Errors, field: String, errorCode: String, @Nullable errorArgs: Array<Any>, @Nullable 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).

Parameters

errors - the Errors instance to register errors on

field - the field name to check

errorCode - the error code, interpretable as message key

errorArgs - the error arguments, for argument binding via MessageFormat (can be null)

defaultMessage - fallback default message