No commit activity in last 3 years
No release in over 3 years
Validation of params for Sinatra
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Sinatra validations

Build Status

I use this library to validate parameters in my Sinatra applications.

It supports defaults and type coercion.

Install

$ gem "sinatra-validations"

Usage

require "sinatra/validations"

class Api < Sinatra::Base
  helpers Sinatra::Validations

  get "/users" do
    validate params, :sort, type: String, default: "desc"
    validate params, :limit, type: Integer, default: 30
    validate params, :filter_by, type: String, default: nil

    # ...
  end

  get "/users/:user" do
    validate params, :user, type: String

    # ...
  end
end

Documentation

Read the tests.