I have the following annotation in an entity:
private Map<@Size(max = 10) String, Chart> charts = new HashMap<>();
When I try to put an object with a long key to the map then I got the following validation error:
{
"errors": [
{
"entity": "Report",
"property": "charts[ffdsfdfdsdsffdsfds]",
"invalidValue": {
"id": 2,
"name": "visitors",
... additional properties ...
},
"message": "length must be between 0 and 10",
"code": "Size"
}
],
}
My problem is that it returns the value of the map-entry as an invalidValue, instead of the key of the entry (which is actually validated).
(This object is really big, with additional lists and maps in it, and all of them are rendered into the error message.)
So, how can I make the validator engine to add
"invalidValue": "ffdsfdfdsdsffdsfds"
into the message? (Or - if it's not possible - how can I turn off adding the invalidValue property to the message - but only at this one particular place?)