dry-rb / dry-schema

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

Allow ignoring key validation #338

Open adamransom opened 3 years ago

adamransom commented 3 years ago

This feature would allow you to be able to opt-out of key validation entirely, rather than having to decide between required and optional, because, for example, we’ve validated earlier that keys are present if they need to be.

It would work like this:

key(:something).filled(:string)

and whether or not the key was present, we would get back a filled? error if the value isn’t present (because either the key is missing or the key is there but no value is).

Originally discussed on Discourse