Skip to content
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

Implement the duration format validator #265

Closed
Stranger6667 opened this issue Jul 27, 2021 · 3 comments · Fixed by #276
Closed

Implement the duration format validator #265

Stranger6667 opened this issue Jul 27, 2021 · 3 comments · Fixed by #276

Comments

@Stranger6667
Copy link
Owner

No description provided.

@floriantz
Copy link

floriantz commented Aug 14, 2021

I have taken a look to see if I could implement this but this might end-up being more difficult than expected.

The json-schema spec duration format is based on ISO8601:

From what I can see, jsonschema-rs relies on the chrono for any time related format validation, but it is currently missing a way to parse and validate ISO8601 Durations.
There was some work on this at some point but it seems it has not moved forward in a while (PR Discussion on the implementation in chrono here)

I've tried to look for an already battle-tested Rust parser for ISO8601 Durations, but I did not manage to find one thus far. So implementing the duration format would also entail implementing a proper parser which could prove tricky since I expect jsonschema-rs should be able to deal with untrusted input.

Since I spent some time researching this I wanted to share it here, which can hopefully clarify the issue a little.

@syheliel
Copy link
Contributor

I found that crate iso8601 provide the api for duration and open a PR #276.

Stranger6667 pushed a commit that referenced this issue Aug 15, 2021
* feat: added duration format validation

* fix: add cfg feature for duration

Ref: #265
@Stranger6667
Copy link
Owner Author

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants