3

I work on REST service using Spring MVC 3.1. Names of some of the object fields are customized. Also I use JSR-303 validation. For example,

@Valid
@JsonProperty("env_vars")
private List<EnvironmentVariable> env;

Works great, but there is an issue here: error messages contains names of Java fields. I mean if user produces invalid value in field *env_vars*, he get an error message that env field contains an error and it can be confusing.

Is there a way to keep names customization without providing full messages for each field?

viator
  • 1,413
  • 3
  • 14
  • 25

1 Answers1

0

Not sure what you mean by "without providing full messages for each field"...

You need to specify the custom field name somewhere, so it may as well use the i18n mechanism for JSR303 - ValidationMessages.properties (see https://stackoverflow.com/a/5781678/249327).

Community
  • 1
  • 1
nickdos
  • 8,348
  • 5
  • 30
  • 47