-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow direct reuse of dry-validation contracts in actions (#454)
Allow dry-validation contract classes to be provided directly to actions. First, via the contract class method, instead of expecting `Hanami::Action::Params` subclasses: ```ruby class MyAction < Hanami::Action contract MyContract # a Dry::Validation::Contract subclass end ``` Second, via a `contract` dependency of the action: ```ruby # Either manually class MyAction < Hanami::Action end action = MyAction.new(contract: MyContract.new) ``` ```ruby # Or in Hanami apps, via Deps class MyAction include Deps[contract: "my_contract"] end ``` This is a more flexible arrangement than requiring these contracts to inherit from `Hanami::Action::Params`, since it will allow contracts to be used across both actions and other non-action classes within Hanami apps. While here, begin to "soft deprecate" the idea of using `Hanami::Action::Params` subclasses. We do this by updating `Hanami::Actions.contract` such that it **does not** support being given `Hanami::Action::Params` subclasses. Given that `.contract` is the new and full-powered incarnation of action validation, this hopefully will nudge people in the right direction.
- Loading branch information
Showing
12 changed files
with
292 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.