This could be supported if we made schemas quack like dry-logic’s Rule (which is actually how it used to work in dry-validation 0.x). Feel free to report a feature request under dry-schema project, it would be great to restore this behavior.
I was trying to migrate my schema to a contract, but as it’s called from another nested schema (I’m implementing a basic validation on a complex struct with multiple levels - OpenAPI JSON schema), I’m a bit stuck.
Is there a “good” way to call a contract from a schema? If not, maybe there’s a way to add some logic to a schema with a small hack? (calling a private method, adding rules on the fly, or something like that?). I’ve been on this for 2 days, reading all the existing examples I could find, without finding any good option.
If there is not easy way to handle this, I’ll wait until the logic handling is implemented at the Schema level! (At the moment I use a JSON schema, but I’d really prefer to implement my validation process with dry-validation).
I gave it a shot and adding | is simple BUT I need to implement dumping composed schemas into dry-logic AST to make this fully work. Could you report an issue in dry-schema about making schemas quack like a dry-logic rule? I think this would be a wonderful addition.