-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Parse dates using ruby's own date parsing - not regular expressions #118
Conversation
Ah, ok. The problem here is that draft-01 through draft-03 specify the
Now, the spec does say SHOULD and not MUST, so there is room for interpretation (as there is for most However, I agree that draft-04 should validate using the build-in ruby method. If you're unsure of how to separate these, I can help. Thanks! |
I'll look at how I can make that happen... |
By the way, there's another unresolved question here - what should the |
Actually, @hoxworth - how would you prefer me to make this conditional on the schema version? My preferred option would be to split the validation for each form type out into it's own method (eg. |
I suppose it would be better to configure supported formats from the validator setup (ie. draft4.rb or draft3.rb) |
@iainbeeston It would probably be best to do the latter of your options - configure the supported formats from the validator setup. I believe right now all formats are currently defined in just the one format attribute file, so this would require a little bit more work. If you'd like I can take this on, but I probably won't get around to it until this weekend or so. |
Hey that's fine - there are a few things I'd like to add to json-schema, so I might as well start with this feature. If you have any ideas how you'd prefer it to be done, please let me know. I'll open a separate pull request for that. I should have time to look at this in two weeks from now (if not sooner) |
Sorry, I haven't had time to refactor the way that the accepted formats are selected (yet). Seems like there are a few pull requests that would benefit! |
I'll revisit this now that #131 has been merged |
own iso8601 parsing method The initial reason for this was that date-time should allow 'YYYY-MM-DD' according to iso8601. Ruby allows this but schema-form did not.
I assume that's a hangover from when they were all in the same file as the uri format
73f44b3
to
784935c
Compare
@hoxworth I've updated this to use the new format classes now. Fixes a few bugs in the date-time parsing in the test suite. Could you please take another look? |
Looks good to me. |
Conflicts: lib/json-schema/attributes/formats/ip4.rb lib/json-schema/attributes/formats/ip6.rb
I've been having problems parsing date-times using json-schema. According to iso8601 'YYYY-MM-DD' is a valid date-time. Ruby respects that, but json-schema does not, because it uses a more simplistic regular expression to match date-times.
I've refactored the parsing of date and time formats to match what's done for URI, where we use the built-in ruby method, and add a validation error if there are any parsing errors.
This has brought up some subtle differences in how json-schema parses dates compared to ruby, for example, case sensitivity. I'd assume that ruby is correct in this, and I've updated the test cases to reflect that.