# How can I get a map.key as invalidValue

**URL:** <https://discourse.hibernate.org/t/how-can-i-get-a-map-key-as-invalidvalue/2095>\
**Category:** Bean Validation (JSR 380)\
**Created:** [January 19, 2019, 8:52pm UTC](https://discourse.hibernate.org/t/how-can-i-get-a-map-key-as-invalidvalue/2095 "2019-01-19T20:52:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Selindek](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Selindek](https://discourse.hibernate.org/u/Selindek)\
**Post date:** [January 19, 2019, 8:52pm UTC](https://discourse.hibernate.org/t/how-can-i-get-a-map-key-as-invalidvalue/2095/1 "2019-01-19T20:52:27Z")

</div>

I have the following validation annotation:

```auto
private Map<@Size(max = 10) String, Chart> charts = new HashMap<>();

```

The validation itself work properly, but in the validation-error object I got the following properties:

```auto
      "code": "Size"
      "property": "charts[qqqqqqqqqqqq]",
      "invalidValue": {
        "id": 2,
        "name": "visitors",
        ... additional properties ...
      },

```

But that’s not what I validated! This message says that the size of a Chart object is invalid under the key ‘qqqqqqqqqqqq’ in the charts map.

I want something like this:

```auto
      "property": "charts.keySet[]",
      "invalidValue": "qqqqqqqqqqqq"

```

It seems to a bug for me.
