Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Integration with
dry-schema
validation library.This extension provides a simple integration with
dry-schema
library to streamline param sanitization.
On its own, the library just provides with a
Conn#sanitized_params
method, which will return what is set intobag's
:sanitized_params
key.This key in the bag is what will be populated by
SanitizeParams
plug, which accepts a
dry-validation
schema that will be appliedto
Conn#params
:By default, when the result of applying the schema is a failure,
Conn
is tainted with a 500 as status code. However, you canspecify your own handler for the unhappy path. It will take the
Conn
andDry::Schema::Result
instances as arguments:A common workflow is applying the same handler for all param
sanitization across your application. This can be achieved setting
a
:param_sanitization_handler
bag key in a upstream operationwhich can be composed downstream for any number of
pipes.
SanitizeParams
will used configured handler if none isinjected as argument. Another plug
ParamSanitizationHandler
exists to help with this process: