Closed
Description
Hey 👋
Sometimes, we can have a huge amount of params to be received in an endpoint. To define all those parameters in the params section can make the received params difficult to read. Additionally, managing custom validations and error messages specific to these parameters becomes challenging.
Due to this, I've seen several implementations where they use dry-validations contract instead of the Grape
params.
post '/charge' do
validation_result = API::V1::Controllers::Contracts::Payments::PaymentsCharge.new.call(parsed_body)
params = parsed_body.deep_symbolize_keys.deep_merge(validation_result.to_h) if validation_result.success?
...
end
Would be great to provide this feature directly by Grape
like:
contract API::V1::Controllers::Contracts::Payments::PaymentsCharge
post '/charge' do
...
end
I can see that we are already using dry-types
for validating params
(#1347 ).