Explicit parameters validation and casting for Rails APIs.
MIT License
Explicit parameters validation and casting for Rails APIs.
Add this line to your application's Gemfile:
gem 'explicit-parameters'
And then execute:
$ bundle
Example:
class DummyController < ApiController
params do
requires :search, String
accepts :limit, Integer, default: 30
validates :limit, :numericality: {greater_than: 0, less_than_or_equal_to: 100}
end
def index
Dummy.search(params.search).limit(params.limit)
end
end
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)