everyone.
So, I have a SpringBoot application with a controller that has several methods, taking the following POJO as a parameter:
package com.example.dto;
import lombok.Data;
@Data
public class MyEntity {
@NotNull
private String fieldA;
private String fieldB;
}
For one of the controller endpoints I would like to apply additional validation logic, so in the validation.xml
I add the following:
<constraint-mappings>
<bean class="com.example.controller.SampleController" ignore-annotations="false">
<method name="doFoo">
<parameter type="com.example.dto.MyEntity">
<valid />
<constraint annotation="com.example.validation.ValidEntity" />
</parameter>
</method>
</bean>
</constraint-mappings>
com.example.validation.ValidEntity
is the constraint annotation I would like to apply.
My problem is that this additional constraint is only invoked if @NotNull
checks defined in MyEntity
have passed successfully. If fieldA
is null, ValidEntity
constraint is ignored, and the client receives an imcomplete validation result. What am I missing?