jimblackler / jsonschemafriend

A JSON Schema loader and validator, delivered as a Java library.
Apache License 2.0
49 stars 23 forks source link

Validate optional formats #18

Closed robbielamb-wf closed 2 years ago

robbielamb-wf commented 2 years ago

This work allows for formats in drafts 2019-09 and 2020-12 to be validated.

jimblackler commented 2 years ago

Could you take a look at the presubmit check failures?

SuiteTest > draft2019_09() > format > time.json > validation of time strings > net.jimblackler.jsonschemafriend.SuiteTest.draft2019_09()[3][15][1][32] FAILED
    org.opentest4j.AssertionFailedError at SuiteTest.java:152

SuiteTest > draft2020_12() > format > time.json > validation of time strings > net.jimblackler.jsonschemafriend.SuiteTest.draft2020_12()[3][15][1][32] FAILED
    org.opentest4j.AssertionFailedError at SuiteTest.java:152

SuiteTest > draft7() > format > time.json > validation of time strings > net.jimblackler.jsonschemafriend.SuiteTest.draft7()[3][14][1][32] FAILED
    org.opentest4j.AssertionFailedError at SuiteTest.java:152
robbielamb-wf commented 2 years ago

Looks like these tests are failing because DateTimeFormatter changed after java 8. I verified the tests fail on my machine with openjdk-1.8 and are passing on openjdk-1.11 and openjdk-1.17.

Looks like the options are to:

  1. Add the tests to the skip lists, so they are ignored when they fail with java 8.
  2. Find an alternative strategy to check the time formats.
  3. Change CI to run on a different java version.

Do you have an opinion on how to fix this?

jimblackler commented 2 years ago

I'd greatly prefer '2', perhaps a different date/time library if one exists that can make the right checks.

robbielamb-wf commented 2 years ago

I've added a regular expression that can check the time format. I created another branch that uses the Joda time library to check the format. It works and I can swap that in if you'd prefer to use the library over a regexp.

jimblackler commented 2 years ago

If the regex does the job then that's fine.