ValidatesAsPostalCode

This Ruby on Rails plugin/gem implements an ActiveRecord validation helper called validates_as_postal_code which validates U.S. postal codes. The helper acts as if validates_format_of was used with a regular expression that defines:

00000 00000-0000

Installation:

gem sources -a gems.github.com

Install the gem(s): sudo gem install gbdev-validates_as_phone_number

Add to environment.rb initializer block: config.gem ‘gbdev-validates_as_postal_code’, :version => ‘>=0.5.0’, :lib => ‘validates_as_postal_code’, :source => ‘gems.github.com

Usage:

In your model file do something like:

class MyClass < ActiveRecord::Base

validates_as_postal_code :postal_code, :message => 'Invalid Postal Code', :allow_nil => true

end

Tests:

Some tests have been added.

License:

See the LICENSE file.