Hi! I’m upgrading dry-validation and dry-types in a project to 1.0 (and dry-struct to 1.1) and I’m having trouble figuring out how to migrate code like this:
Dry::Validation.Params do optional(:foo).maybe(:hash?) do schema do optional(:bar).maybe(:bool?) optional(:baz).maybe(:bool?) optional(:qux).maybe(:str?) rule(bar: [:baz, :qux]) do |baz, qux| baz.true?.then(qux.filled?) end end end end
I can migrate the schema to
Dry::Struct.Params and other code but the rules seem to be problematic since dry-struct doesn’t support them. I’ve tried to use a contract instead but I don’t see any way to have dependencies on the hash keys like the code above (where
qux are keys on the
foo hash, and their rules depend on each other).
Is this type of thing not supported out-of-the-box anymore? If so, what would be the most “dry” way to achieve it?
Thanks for any help, and thanks for the great gems!