Default implementation of the MessageCodesResolver interface.
Will create 2 message codes for an object error, in the following order:
1.: code + "." + object name
2.: code
Will create 4 message codes for a field specification, in the following order:
1.: code + "." + object name + "." + field
2.: code + "." + field
3.: code + "." + field type
4.: code
E.g. in case of code "typeMismatch", object name "user", field "age":
1. try "typeMismatch.user.age"
2. try "typeMismatch.age"
3. try "typeMismatch.int"
4. try "typeMismatch"
Thus, this resolution algorithm can be leveraged for example to show
specific messages for binding errors like "required" and "typeMismatch":
at the object + field level ("age" field, but only on "user");
at the field level (all "age" fields, no matter which object name);
or at the general level (all fields, on any object).
In case of array, List or Map properties, both codes for specific
elements and for the whole collection are generated. Assuming a field
"name" of an array "groups" in object "user":
Will create 2 message codes for an object error, in the following order:
Will create 4 message codes for a field specification, in the following order:
E.g. in case of code "typeMismatch", object name "user", field "age":
Thus, this resolution algorithm can be leveraged for example to show specific messages for binding errors like "required" and "typeMismatch":
In case of array, List or Map properties, both codes for specific elements and for the whole collection are generated. Assuming a field "name" of an array "groups" in object "user":