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

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

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

Parameters

errors - the Errors instance to register errors on

field - the field name to check

errorCode - error code, interpretable as message key

defaultMessage - fallback default message

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

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 rejectIfEmpty(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.

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

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