Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add an optional 'prefix' property to DefaultMessageCodesResolver [SPR-2875] #7562
Add an optional 'prefix' property to DefaultMessageCodesResolver that allows for a system-enforced convention for validation failure messages codes. This is important on large i18n projects (with thousands of message codes) for providing grouping / context.
To extend the example provided in DefaultMessageCodesResolver (using a prefix of 'validation'):
I've attached a sample of how we have accomplished this - having the prefix property would be simpler/cleaner.
Another option to consider would be refactoring the code construction into overridable methods (buildCode(errorCode,objectName,field) and buildCode(errorCode,field), which opens up possibilities beyond the simple addition of a prefix.