Change error message for Play JSON to be like Play #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Play JSON, a small number of constant strings are used for validation errors. These can then be localized. It also enables non-Play code to use this message, combined with the path specifying the bad field's location, to generate useful messages.
This change modifies the Play JSON
Reads
for enums to use strings already in use in Play. Although on their own they are less informative than what's there now, they fit in better with Play and when combined with paths can be used to make more informative messages. (This is our use case. We're not using the play framework but expecting Play JSON behaviour. With current enumeratum behavior we have to prefix-match the error string to generate our errors, but match constant strings for other fields).If you prefer I can make this an optional thing, like case-insensitivity, but I thought I'd propose this simpler change first.