No release in over 3 years
Low commit activity in last 3 years
Boolean validator for ActiveModel.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 5.0.0
 Project Readme

BooleanValidator

This gem enables your Rails-based app to validate boolean values much easier.

Installation

Add this line to your application's Gemfile:

gem 'boolean_validator'

And then execute:

$ bundle install

Usage

In your model:

class Post
  include ActiveModel::Model
  validates :is_public, boolean: true
end

or you can pass an option like:

class Post
  include ActiveModel::Model
  validate :is_public, boolean: { message: 'Customize your error message' }
end

Contributing

  • Note: With ActiveRecord, this validation does not work functionally and just work as column type declaration.
  • Implementation for ActiveRecord is here: #4
  • Bug reports and your opinions are welcome.

License

The gem is available as open source under the terms of the MIT License.