Sha256: b0ab3b409c20b95b3e55fe3ddd318236ab8d5e2448c5d23fa9ff7787932196e2

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

# ValidatesZipcode

Add zipcode validation support to Rails (ActiveModel), considering different zipcode country formats.

Currently supported country zipcodes are: USA, Canada, Spain, New Zeland, Australia, Colombia and Argentina.
Any other country's zipcode will validate without errors.

## Installation

Add this line to your application's Gemfile:

    gem 'validates_zipcode'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install validates_zipcode

## Usage

    validates_zipcode :zipcode

    validates :zipcode, zipcode: true

``ValidatesZipcode`` expects the model to have an attribute called ``country_alpha2`` to contain the country code.
You can provide your own country_code using ``:country_code`` option, or specify which attribute contains this information
using ``:country_code_attribute`` option.

    validates :zipcode, zipcode: { country_code: :es }

    validates :zipcode, zipcode: { country_code_attribute: :my_country_code_column }

If you need to localize the error message, just add this to your I18n locale file:

    errors:
      messages:
        invalid_zipcode: Your zipcode error message.

## Contributing

1. Fork it ( https://github.com/[my-github-username]/validates_zipcode/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

To see the generous people who have contributed code, take a look at the {contributors list}[http://github.com/dgilperez/validates_zipcode/contributors].

## Maintainers

* {David Gil}[http://github.com/dgilperez]

## License

Copyright (c) 2014 David Gil PĂ©rez, released under the MIT license

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_zipcode-0.0.1 README.md