Validation nested models in spring boot
<p>I have a problem with validation of nested models, look:   </p>

<pre><code>class A{
   @NotNull
   Integer i;
   B b;
}
class B{
   @NotNull
   Integer j;
}
</code></pre>

<p>In spring controller:<br>
<code>@Valid @RequestBody...</code></p>

<p>It properly validate <code>i</code>, but not validate <code>j</code>.   How to force Spring to validate arbitraly deep ?   </p>

<p>And second thing:<br>
Is it possible to do following validation:   Object of class 'A' is proper only and only if exactly one of <code>i</code> an <code>j</code> is <code>null</code>.   </p>

<pre><code>class A{
   Integer i;
   Integer j;
}
</code></pre>