So I'm looking at adding constraints to my json views.
I have class similar to this one
public class Person {
@JsonProperty(required = true)
@NotNull
@Size(max = 50)
private String name;
}
Should I keep both @JsonProperty(required = true)
and @NotNull
or should I remove one and why?
Just to be clear since Jackson 2.6 @JsonProperty(required = true)
does throw an exception.
I'm using springfox-swagger and it looks like when I remove @JsonProperty(required = true)
the field in the swagger is marked as optional which it isn't.
I'm just wondering about the best practice in this situation.