ssato / python-anyconfig

Python library provides common APIs to load and dump configuration files in various formats
MIT License
278 stars 31 forks source link

Get all validation errors in an Dict #79

Open edyan opened 7 years ago

edyan commented 7 years ago

Hi,

For now the validate() method returns only the first encountered error. I would like to know if we can get all, in a dict for example: { 'keya': ["True is not of type 'string'"], 'keyb': ["True is not of type 'string'"] }

Also, I noticed that the doc here https://github.com/ssato/python-anyconfig/blob/master/anyconfig/schema.py#L45 is not up to date. safe is not part of options ;)

Thanks !

ssato commented 7 years ago

Thanks for the report!

For now the validate() method returns only the first encountered error. I would like to know if we can get all, in a dict for example: { 'keya': ["True is not of type 'string'"], 'keyb': ["True is not of type 'string'"] }

I'm not sure it's possible but will take some time to study it. Please wait for a while.

Also, I noticed that the doc here https://github.com/ssato/python-anyconfig/blob/master/anyconfig/schema.py#L45 is not up to date. safe is not part of options ;)

You're absolutely right I'll also look into this maybe this weekend.

ssato commented 7 years ago

I think that a couple of commits like 518d7bc improve the following:

Also, I noticed that the doc here https://github.com/ssato/python-anyconfig/blob/master/anyconfig/schema.py#L45 is not up to date. safe is not part of options ;)

You're absolutely right I'll also look into this maybe this weekend.

ssato commented 7 years ago

Very sorry to late reply.

I add support of this function in an experimental branch named 'schema'. Could you please look at the commit 6447858 (especially its test case) and try it if possible?

If it looks OK, I'll merge it.

edyan commented 7 years ago

Hi Satoru

Thanks for doing that. I would say it's not far from being perfect (from my point of view). The message is clear but .... (sorry for the bug) we don't know what messages belongs to what key.

In your example, I would expect : {"a": ["'abc' is not of type 'boolean'"]}

If that's doable that would be great.

Thanks again Emmanuel

ssato commented 6 years ago

I took some time to accomplish what you want, but unfortunately, I think that it's very hard to do that w/o modifying jsonschema other than anyconfig.

Now, I merged the change I did as an workaround to master branch instead as an workaround and keep this issue open.