-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issues with float, None and scientific notation #39
Comments
Hi. Can you provide an example of the data in yaml format that you are trying to validate? I think that if pyyaml do not automatically convert the data on load then i am not sure if it is currently possible or not. If you build a datastructure in python and use the About multiple types for mappings, it was not part (to my knowledge) of the original pykwalify standard. I have tried to not include to much new stuff into pykwalify that extends the original framework. But there might be 1 possibility that you could explore. You could possibly set |
Hm, yes, you are right, yaml doesn't parse the scientific notation as a float but as a string. example:
output:
|
Sorry, i've been mixing up parsing yaml and json in my example. here an other example
output:
so the problem is indeed in the yaml parsing (shouldn't parse json with jaml parser anyway). When parsed with the json parser it works. Sorry for the confusion. Still having support for multiple types for a value in a mapping would be very useful! |
Related to your suggestion to setting the required filed to silence the None error, that doesn't seem to work:
output:
|
Hmm that is true that it should not silence them, the type validation will still fail, required for mappings is that data can be allowed to be missing. The main problem with adding some kind of support for multiple type validations for a key is that how the synxat should be changed to still preserv backwards compatibility with kwalify but at the same time add this new feature and also at the same time not making the syntax super horrible. |
so currently syntax for a mapping is:
How about adding a keyword
I don't see any backward compatibility issues there and it makes sense. |
I like the idea, but i do think that problems could apear that makes it abit more complicated to code and work with. Depending on what |
The following commit 4372ade fixes the scientific notation part of the problem. The multiple types in mapping is still a open problem, but i have been thinking about it some and i might have some ideas on how to possibly support it, but it will take some time to test it out and possible implement it. |
awesome, thanks! |
let me know if you need some input or to share some thoughts. |
@gijzelaerr Would you mind if i close this one as fixed because of the scientific notation fixes that is included in |
sure! 2016-03-07 14:10 GMT+02:00 Grokzen notifications@github.com:
Gijs Molenaar |
Ticket created. Closing this because scientific notation was fixed in |
Hi!
I'm trying validate some json I have. The json contains a mapping with float values. pykwalify probably correctly pykwalify doesn't accept float values like 1e-06 and None:
So 2 questions (or maybe issues):
awesome, thanks!
The text was updated successfully, but these errors were encountered: