dry-rb / dry-schema

Coercion and validation for data structures
https://dry-rb.org/gems/dry-schema
MIT License
422 stars 110 forks source link

Make path matching in key validator more strict #386

Closed pharmaceutics closed 2 years ago

pharmaceutics commented 2 years ago

Fixes #385

Loose matching was added to allow partial key paths to pass the validate_keys validation when used with maybe hashes (#309, #312). This change maintains that behaviour, but prevents paths with partial keys from passing.

Originally, went with a regex solution but it turned out to be pretty sluggish when benchmarked. This version doesn't seem to have any noticeable impact on performance, at least for simple cases I tested.

flash-gordon commented 2 years ago

LGTM 👍