improve error message for missing required props#176
improve error message for missing required props#176horejsek merged 1 commit intohorejsek:masterfrom
Conversation
only include _missing properties in the error message for required props
```
>>> fastjsonschema.validate({'required': ['foo', 'bar']}, {'foo': 1})
```
before:
```
JsonSchemaValueException: data must contain ['foo', 'bar'] properties
```
after:
```
JsonSchemaValueException: data must contain ['bar'] properties
```
|
Thanks for the pull request. I measured this is actually also slightly faster on my computer, which surprised me. |
|
Thank you! Any chance of a new release with this in? |
maybe marginally faster since there is less string formatting to do? |
|
I just released 2.18.0 with an additional fix. In the morning I tested only happy path. That is, if you require ten props and all of them are there, the whole iteration must be done anyway. But I see your version is slower in case some prop is missing. More missing props, faster original solution is (it also depends on the order of the props) - it simply stops with the first missing item without need to compute the whole diff. Considering it is slower only in unhappy cases for specific schemas and only slightly, I say it is OK. |
only include _missing properties in the error message for required props
before:
after:
fixes #175