Giter Club home page Giter Club logo

telefonia_br's Introduction

Telefonia BR

This gem does some tricks with Brazilian Telephone Numbers. It validates telephone numbers based on its area code, bands of operation and the rules defined by ANATEL. The implementation of the ninth digit in Brazil has also been taken into account when developing this gem.

API to illustrate its functionality: http://telefonia-br.herokuapp.com?tel=(YY)XXXXXX

Installation

Add this line to your application's Gemfile:

gem "telefonia_br"

And then execute:

$ bundle

Or install it yourself as:

$ gem install telefonia_br

Usage

require "telefonia_br"

tel = TelBr.new("(YY)XXXXXXXX")  

tel.stripped          # Return stripped telephone: YYXXXXXXXX
tel.formatted         # Return formatted telephone: (YY) XXXX-XXXX

tel.ddd               # Return the DDD: YY
tel.state             # Return the state, such as "SP" for DDD 11 to 19
tel.region            # Return the region, such as "São José dos Campos e Região." for DDD 12

tel.number            # return the number: XXXXXXXX

tel.valid?            # Check if a telephone number is valid
tel.error             # Display the error if telephone number is invalid

Error Messages

If a telephone number is invalid you might get one of the following messages:

Invalid telephone
Invalid DDD
Invalid number
Number should have 8 digits
Number should have 9 digits

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-contribution)
  3. Commit your changes (git commit -am "your message")
  4. Push to the branch (git push origin my-contribution)
  5. Create a new Pull Request

telefonia_br's People

Contributors

gabrielhilal avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.