validate

fun <C : Any> C.validate(): C

Validates this object using Jakarta Bean Validation and throws an exception if validation fails.

This extension function performs validation on the receiver object using the TestValidator. If the object implements CommandValidator, it first calls the custom validation logic. Then, it validates the object against Jakarta Bean Validation constraints. If any constraint violations are found, it throws a CommandValidationException.

Receiver

The object to validate.

Return

The same object if validation passes.

Parameters

C

The type of the object being validated, must be a non-null type.

Throws

CommandValidationException

If validation fails due to constraint violations.

Samples