Spring Service method validation
It is considered a good practice to validate the inputs of your service method.
You need to first annotate your service class with
In order to avoid a
If the input is invalid, a
You need to first annotate your service class with
@Validated. This annotation tells Spring to evaluate the constraints annotations on each method parameters.In order to avoid a
ConstraintDeclarationException, your interface should also declare the constraint annotations.If the input is invalid, a
ConstraintViolationException is thrown.
Comments
Post a Comment