I’m trying to use validation in service methods called from Rest API,
for example I have the method:
public String ope1 (@NotNull Srv1Ope1ReqDTO req, @NotNull String str)
inside the Srv1Ope1ReqDTO class I have the property with @NotNull:
private BIN bin;
If I call the method from Postman the validation works only for the second parameter (“str”) but not for the first (req).
if I use programmatic validation in the method body:
Validator validator = beanValidation.getValidator();
Set<ConstraintViolation> violations = validator.validate(cb);
it works (violations is not empty if req.bin is null).
Can you help me yo understand my mistake?
Thankyou very much