brandur / json_schema

A JSON Schema V4 and Hyperschema V4 parser and validator.
MIT License
230 stars 45 forks source link

`Validator#validate_type` no longer admits subtypes #97

Closed chrisandreae closed 6 years ago

chrisandreae commented 6 years ago

In https://github.com/brandur/json_schema/commit/d110c244b7d3d5121273fa52b636095edbdbac22#diff-50b1d22f09d5badf9130a7c63a618c46R505, Validator#validate_type was changed to require strict == equality for data types rather than the previous is_a? subtype check.

This means that subclasses of the mapped types are no longer accepted. Was this an intended change?

One common use case that this now prevents is ActiveSupport's HashWithIndifferentAccess.

brandur commented 6 years ago

Doh! Thanks for the heads up.

@breunigs Do you think it might be possible to get this back on the old behavior?

breunigs commented 6 years ago

Oh, sorry about that! I didn't consider this use case, but it makes total sense. There's not even a performance benefit for doing it the way I did. Anyway, patch is in #98.

brandur commented 6 years ago

A fix has been pushed as part of 0.19.1. (Thanks @breunigs!)

chrisandreae commented 6 years ago

Cheers, thanks for the quick fix!