must have at least 2 characters.
Change it in three places, from the broadest to the narrowest.
For the whole application
messages { } in the configuration changes the default message of a constraint everywhere.
Each message is a property named after the constraint:
For one call
The same block insideValidity { } changes them for one validation only, which is how a server answers each request
in its own language:
For one rule
Every constraint takes amessage, which replaces the default for that call:
Placeholders
A message can use placeholders in braces, filled in when the violation is built:The message of a constraint is not always its name
Most messages are named after their constraint, but a few constraints share a name across types and need different words. The size rules of a map count entries, not items, and the Boolean rules cannot be namedisTrue:
The constraints reference gives the message of every constraint. The code of the violation is
always the name of the constraint.
Messages of a country
The constraints of each country have their messages in a block of their own:brazil, bulgaria, canada, france, israel, netherlands, pakistan, poland, russia,
slovenia, spain, thailand, ukraine and unitedStates.
Messages of a module
A module such asvalidity-phone adds its own block to messages:
Messages of your own constraints
Your custom constraints can have configurable messages too. Hold them in a class, declare aMessagesKey for it, and read the current messages from the key:
module:
MessagesKey.current reads the messages of the configuration that is validating, so Validity { } for one call works
for them too.