No release in over 3 years
Low commit activity in last 3 years
A simple set of validations I got tired of writing over and over and over again.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 5.2.3
 Project Readme

simple-validations-rails Gem

A simple set of validations I got tired of writing over and over and over again. Includes boolean, locale, and email validators.

Installation

Add this line to your application's Gemfile:

gem 'simple-validations-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple-validations-rails

Usage

It's a set of validators...and is therefore used like other validators.

Boolean Validator

Validates that the value is boolean in nature.

# Allows only non-null booleanish values (most values that aren't nil are true - but in this case, nil is NOT false, and thus fails).
validates :allow_something, boolean: true

# Allows basically anything. Probably this is useless...
validates :preference_that_can_be_null, boolean: {allow_nil: true}

# Allows ONLY true or false.
validates :strict_preference, boolean: {strict: true}

# Allows ONLY true, false, or nil.
validates :strict_preference_that_can_be_null, boolean: {strict: true, allow_nil: true}

Locale Validator

Validates that the value is within the allowed locales for the application.

# Allows strings/symbols, checks against available locales.
validates :locale, locale: true

# Same as above, but nil is valid.
validates :locale, locale: {allow_nil: true}

Timezone Validator

Validates that the value is a valid timezone.

# Allows strings/symbols, checks against available locales.
validates :time_zone, timezone: true

# Same as above, but nil is valid.
validates :time_zone, timezone: {allow_nil: true}

Email Validator

TODO: Documentation

License

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