Skip to content

rspine/parameters

Repository files navigation

Spine::Parameters

Gem Version Dependency Status Test Coverage Code Climate security Inline docs Codeship Status for rspine/parameters

Validates and converts parameters. Also it converts all keys to symbols.

Installation

To install it, add the gem to your Gemfile:

gem 'spine-parameters'

Then run bundle. If you're not using Bundler, just gem install spine-parameters.

Usage

parameters = Spine::Parameters::Collection.new(parameters_containing_hash)
parameters.required(:name)
  .integer(:id)
  .timestamp(:since)
  .boolean(:valid)
  .list(:favourites)

parameters.errors? # Checks if there is any parsing error.
parameters.errors
# => { id: ['invalid number'] }

parameters[:since]
# => <DateTime: 2014-01-01T12:00:00+00:00>

About

Validates and converts web application parameters.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages