Reputation: 1415
I'm writing a Java based, Spring REST web service. I'm wondering if there is a way to exclude some object validations for HTTP PATCH
.
Basically, what I need is to validate the same object differently for HTTP POST
and for the HTTP PATCH
. For example, when HTTP POST
request is received i need to include @NotNull
validation for fields, HTTP PATCH
doesn't need to check if field is null.
Upvotes: 0
Views: 413
Reputation: 8324
You can use Bean Validation using groups.
@NotNull(groups=Group1.class)
private String field;
@NotNull(groups=Group2.class)
private String field;
You can see more here.
http://www.jroller.com/eyallupu/entry/jsr_303_beans_validation_using
Upvotes: 2