Using schemas, contracts with dry-rails

In the docs for dry-rails:

https://dry-rb.org/gems/dry-rails/0.3/

It talks about defining schemas to use with safe_params, and separately about defining contracts. As the latter would also need a schema, is there a pattern for sharing the schema between the controller and a contract?

1 Like

Hey Paul! There’s no pattern yet but I’m planning to come up with something eventually. It’s actually one of my personal pet peeves :wink: Conceptually, params received at the HTTP level is a different thing than params that your underlying app receives, but there’s obviously a lot of overlap so we definitely want to reduce code duplication. My rough idea is to be able to define an HTTP-specific schema and then have a way of translating it automatically to a contract schema. How exactly this would look like is yet to be determined.

1 Like