No commit activity in last 3 years
No release in over 3 years
Brazilian zipcode validations for ActiveRecord, integrated with correios-cep gem.
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

validates-correios-cep

Gem Version Gem CI license

Installation

Add this line to your application's Gemfile:

gem 'validates-correios-cep'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install validates-correios-cep

Usage

ActiveRecord models

class Person < ActiveRecord::Base
  validates :my_attribute, correios_cep: true

  # or

  validates_correios_cep_of :my_attribute
end

Plain Old Ruby Objects

class Person
  include ActiveModel::Model

  validates :my_attribute, correios_cep: true

  # or

  validates_correios_cep_of :my_attribute
end

I18n

To customize your error messages you can create a locale file like this:

en:
  correios_cep:
    errors:
      messages:
        not_exists: '%{zipcode} is not a existent Brazilian zipcode'
        connection_failed: 'failure on connection with Brazilian Correios API'
        invalid: '%{zipcode} is not a valid Brazilian zipcode'
        timeouted: 'timeout with Brazilian Correios API'

The %{zipcode} contains the zipcode value, filled by user.

Something wrong with the translations? Contribute it!

Send a pull request! Fix the translations or create it for some missing locale. Help us to improves the quality of translations!