I do validation with JSR-303
in my Spring app, it works as needed.
This is an example:
@Column(nullable = false, name = "name")
@JsonProperty("customer_name")
@NotEmpty
@Size(min = 3, max = 32)
private String name;
And REST API clients use customer_name
as name of input field that send to API bud validation field error org.springframework.validation.FieldError
returns name
as name of the field.
Is there some way hot to get JSON-ish
name that is specified in @JsonProperty
? Or do I have to implement own mapper to map class fields name into its JSON alternative?
Edit1: Renaming class fields into names that correspond to JSON names is not alternative (for many reasons).