jonasschmidt / ex_json_schema

An Elixir JSON Schema validator
MIT License
366 stars 98 forks source link

fix date-time format validation #58

Closed ananthakumaran closed 3 years ago

ananthakumaran commented 4 years ago

The current regex to validate date-time doesn't capture all the invalid dates. Also the spec mandates proper day validation, that is, february can't have 29 on non leap year etc which can't be validated via regex.

This commit uses the DateTime module from standard library to do the validation. Given that the function is available since 1.4, support for 1.3 is dropped.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.006%) to 98.701% when pulling 8b4cc41b539128c2c45233b23c0c4eb9dbf6ec79 on ananthakumaran:fix-date-time-validation into 68a3f7a2bc2da3d91f7cef8752b5f3b98d072a4f on jonasschmidt:master.

jonasschmidt commented 4 years ago

Great idea. Back when I initially implemented this there was no proper date/time support in Elixir so I went with the Regex approach. Dropping support for 1.3 sounds like a reasonable trade-off at this point.

I also just realized that the Travis build isn't properly integrated with Github so we can't see the build status in the pull request. I will have to look into fixing that.

jonasschmidt commented 4 years ago

Ok, so there seems to be a failing test in the official test suite, can you have another look at that? https://travis-ci.com/github/ananthakumaran/ex_json_schema/builds/155739838

ananthakumaran commented 4 years ago

Updated the code to handle case sensitivity. I had a different commit of the submodule checked out earlier.

jonasschmidt commented 3 years ago

Fixed in https://github.com/jonasschmidt/ex_json_schema/pull/64