In my springboot app I'm using PATCH
HTTP method to update an entity. Of course via DTO, not directly.
Since this is PATCH
method I'm not all fields will be set and I want to validate (in terms of javax.validation.constraints
package) only those fields that have value set (!=null).
So I have:
class SomeDTO {
@Size(min = 5)
String foo;
@Min(2)
Integer bar = 1;
}
and need to validate bar
field only, since foo
has null value. What is the best mechanism for handling such requirements?
I'm using: 1.5.6.RELEASE