kgiszczak / shale

Shale is a Ruby object mapper and serializer for JSON, YAML, TOML, CSV and XML. It allows you to parse JSON, YAML, TOML, CSV and XML data and convert it into Ruby data structures, as well as serialize data structures into JSON, YAML, TOML, CSV or XML.
https://shalerb.org/
MIT License
618 stars 19 forks source link

Add support for JSON Schema validation keywords #29

Closed bkjohnson closed 8 months ago

bkjohnson commented 8 months ago

Closes #28

This PR implements most of the "validators" vocabulary for the 2020-12 draft of JSON Schema. Specifically it allows the following properties to be used on the following types:

Numeric (Integer and Float shale types)

String

The format keyword from the Format Annotation vocabulary is also allowed.

Array (Collection shale type)

Object


This PR doesn't add support for the remaining keywords for "any" type:

Lastly, right now these don't receive any sort of validation other than making sure that the wrong keywords don't get added to the wrong types.

bkjohnson commented 8 months ago

@kgiszczak I'd be happy to add an example or two to the README once you're satisfied with the changes.

kgiszczak commented 8 months ago

@bkjohnson it looks really great, and yes please add some examples to README.

Outstanding items to do:

  1. Add examples to readme
  2. Make sure 100% test coverage
  3. Run it through rubocop and make sure no warnings

Thank you, outstanding job.

kgiszczak commented 8 months ago

Some more changes I forgot about:

  1. Update changelog with your change (add it to unreleased section) e.g
    
    ## [1.1.0] - [unreleased]

Added

bkjohnson commented 8 months ago

Test coverage shows 100% and there are no rubocop warnings for the lib/ or spec/ directories. I limited it this way because there are a number of rubocop warnings in the benchmarks/ directory and gemspec.

image

Also, did you know about GitHub's "Squash and Merge" feature? It's a repo setting, but it can let you squash a PR into a single commit for merging.

You'll see it in the merge button dropdown:

image

Here are some more details including how to change the default commit message for the squash commit.

kgiszczak commented 8 months ago

Awesome job, thank you.