-
Notifications
You must be signed in to change notification settings - Fork 84
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
The "any" type does not accept non-implemented types like timestamp #14
Comments
@sitaktif When you say timestamp do you mean a string or integer like "1426059442" || 1426059442 or do you mean that your object is a python datetime object? Is it possible that you can provide a sample schema file and data file so i can test the problem myself? The reason behind throwing the validation error is simple and that is because i have to implement the check for a given type and that is what any is for. A improvment upon this problem might be to implement a lower type then any that basiclly do nothing and accepts anything perhaps? |
@sitaktif Your question answers itself i think because the docs state how it works and that will not change any time soon. A simple solution could be to use |
@Grokzen Thanks for your answer! And to clarify, by timestamp I meant something that looks like
I am not sure I understand why you have to check for all the types that The current meaning for Also, accepting any type (even the non-implemented ones) with This is maybe not particularly relevant to the development of Pykwalify, but to give you one data point, the main reason I got interested in Pykwalify was that I could use the same Yaml schema in different languages. This is why compatibility between the different kwalify libraries is important to me -- but again I understand this might not be one of your goal maintaining this particular lib. |
The original documentation is lacking with the defenition of the major difference between, time, date and timestamp. I would say that here in the python version it could be defined as
>>> import time
>>> time.time()
1427595892.498187 It could be valid with or without decimal numbers but it could be configurable.
I understand your argumentation with the |
I agree the Kwalify documentation is lacking on this but putting Kwalify (and Pykwalify) aside, we should follow standards and not come with our own recipes. Doing it in a Pythonic way is not necessarily the right way to go (and believe me, I love the pythonic way :-) ) because Yaml is a concept that is language agnostic. You can see an example of timestamps in the Yaml official standard on [http://www.yaml.org/spec/1.2/spec.html#id2761573](see the "Example 2.22. Timestamps" section). It follows the ISO8601 format (see http://en.wikipedia.org/wiki/ISO_8601), which is one of the widely used standards for timestamps (or what we would call datetime). Btw, the way I described above is the way Kwalify behaves. You can look at the code, but I built an example to be sure:
The code for
That's good to know. It's a backward incompatible change so it's probably better to postpone it to a sort of "major" release, but I think it's good to keep this change in mind. Thanks! |
If i change the Your exampleis very good and i can easily try to implement something similar to that. |
@sitaktif Do you know some good list or site or something that could help to determine what formats to support out of the box? I am thinking about adding ability to manually specify what formats that you want for a datetime but there must be a default set also. |
Timestamp implemented in c5a4782 Will be included in next tag/release. |
The If you have any comments or suggestions on the |
@Grokzen Nice! This is coming a bit late (sorry...) but I do have a suggestion about what formats to support: why don't we use Using the yaml library to parse the date delegates this kind of decision to the people maintaining the yaml lib and ensures the formats are aligned. EDIT: I'll open a new issue to discuss this. |
The documentation specifies that
any
accepts any implemented type.Is there a reason behind throwing a validation error when one uses other non-implementd types like timestamps?
I understand that a possible fix in my case is to send a PR to add timestamps support - and I'll do that if I get around to it :-)
Thanks,
The text was updated successfully, but these errors were encountered: