Sha256: f64fb29df684e6d90bdaa26360a9fef380c4a4a642af358d2d41cd95ac74565b

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

h1. Localized @EachValidator@

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

h2. 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.

h2. 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:

<pre><code>
class FourValidator < ActiveRecord::EachValidator
  error_key :must_be_four

  def valid?(record, field, value)
    value == 4
  end
</code></pre>

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

<pre><code>
en:
  activerecord:
	errors:
	  messages:
	    must_be_four: This number must be four.
</code></pre>


See the {LocalizedEachValidator} class documentation for more information.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
localized_each_validator-1.0.3 README.textile