Sha256: 724f8da2db02c5baee485c78b51db048f10599ade6583d3a98e1ba58d07d287a

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

= ValidatesTelephone {<img src="https://secure.travis-ci.org/plribeiro3000/validates_telephone.png" />}[http://travis-ci.org/plribeiro3000/validates_telephone]

Rails gem to validate Telephone.

== Install

gem install validates_telephone

== Usage

Lets say you have a model with "telephone" string column that you want to be a valid telephone for Brazil. Just add this to your model:

class User < ActiveRecord::Base
    validates :telephone, :telephone => true
end

In case you want it to be a valid telephone for United States, just pass the locale as en:

class User < ActiveRecord::Base
    validates :telephone, :telephone => { :locale => :usa }
end

== Test

This gem has matchers for shoulda-matchers and remarkable.

If you want the matchers for Brazil and you are using shoulda-matchers, add this line to your spec_helper.rb :
    require "validates_telephone/shoulda-matchers/validate_as_br_telephone_matcher"
If you want the matchers for Brazil and you are using remarkable, add this line to your spec_helper.rb :
    require "validates_telephone/remarkable/validate_as_br_telephone_matcher"

If you want the matchers for United States and you are using shoulda-matchers, add this line to your spec_helper.rb :
    require "validates_telephone/shoulda-matchers/validate_as_usa_telephone_matcher"
If you want the matchers for United States and you are using remarkable, add this line to your spec_helper.rb :
    require "validates_telephone/remarkable/validate_as_usa_telephone_matcher"

=== How?

You should use validates_as_telephone(:attribute) just like any other shoulda or remarkable matcher.

== Future

Add Support for other countries. For now it only supports Brazil and United States telephones.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validates_telephone-0.2.1 README.rdoc
validates_telephone-0.2.0 README.rdoc