This is my scenario
class B {
@NotNull
String x;
}
class A {
@Valid
B b;
@NotNull
String y;
}
Now my Http POST request gets an object of class A as the payload. String y should be validated in the incoming HTTP request (and also validated before persisting to DB). However String x should NOT be validated in the incoming HTTP request (and only validated before persisting to DB) since String x will be null in the request and its value will be set by the business logic before the full class A object is persisted.
Is there any way to accomplish this ?