No release in over 3 years
Low commit activity in last 3 years
Adds an abstract EachValidator superclass that you can use to create localizable validations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Localized EachValidator

Author Tim Morgan
Version 1.0.3 (Jul 23, 2013)
License Released under the MIT license.

About

Localized EachValidator is a subclass of ActiveRecord's EachValidator that makes it easier to write a localized validator with Rails 3's localization. It's small and simple.

Usage

Add this gem to your project's Gemfile, or to your own validator gem's dependencies. Then, sublass LocalizedEachValidator and provide the error_key and override the valid? method, like so:

class FourValidator < ActiveRecord::EachValidator
  error_key :must_be_four

  def valid?(record, field, value)
    value == 4
  end
end

Now, users of your validator can create a localization YAML file like so:

en:
  activerecord:
	errors:
	  messages:
	    must_be_four: This number must be four.

See the {LocalizedEachValidator} class documentation for more information.