• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@NotNull annotation with validation.properties with {0} is required field

 
Jacob Sonia
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we substitute the field name being validation with {0} when emitting out the message.
 
Knute Snortum
Bartender
Pie
Posts: 2897
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not exactly clear on what you want to do. Could you post a short example of the code you want to change? Or give us a little more detail.
 
Campbell Ritchie
Sheriff
Posts: 51368
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also please explain which framework you are using; there is no NotNull class in the standard Java8 API. There is an annotation of that name in the JavaEE API however.
 
Jacob Sonia
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this custom message in my ValidationMessage.properties ->
missing.startDate= startDate is a required field.

I have this on my request
@NotNull(message="{missing.startDate}")

Now, this forces me to create a message for each field. If i could do something like this
In ValidationMessage.properties
missing = fieldName is a required field. OR
missing = {0} is a required field.

@NotNull(field="startDate") or just have it as @NotNull

@NotNull is for javax
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic