Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/byroot/explicit-parameters

Explicit parameters validation and casting for Rails APIs.
https://github.com/byroot/explicit-parameters

Last synced: 5 days ago
JSON representation

Explicit parameters validation and casting for Rails APIs.

Awesome Lists containing this project

README

        

# ExplicitParameters

[![Build Status](https://secure.travis-ci.org/byroot/explicit-parameters.png)](http://travis-ci.org/byroot/explicit-parameters)
[![Gem Version](https://badge.fury.io/rb/explicit-parameters.png)](http://badge.fury.io/rb/explicit-parameters)

Explicit parameters validation and casting for Rails APIs.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'explicit-parameters'
```

And then execute:

$ bundle

## Usage

Example:

```ruby
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
```

## TODO

- Real README

## Contributing

1. Fork it ( https://github.com/byroot/explicit_parameters/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request