Sha256: 2d4dc7f41d2614114a6076ef8e4e219bbbb4682237ae4ed9f4ce46b11b013820

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

= Phone Number Validator

== About

This app is a US phone number-validating RubyGem.

It uses a complex regular expression to validate any United States phone number.

=== Regular Expression

This gem uses the following regular expression:

  # US Phone Numbers
  /^(?:(?:[2-9]11)|(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:\x20+|#|x\.?|ext\.?|extension)\s*(\d+))?)$/i
  # Regex Flags: i (ignore case)

== Installing

  $ gem install phone_number_validator

=== Install Required Gems/Dependencies

  $ bundle install

=== Updateing Required Gems/Dependencies

  $ bundle update

== Uninstalling

  $ gem uninstall phone_number_validator

== Testing

  $ rake test

== Usage

=== In command line

  $ phone_number_validator '+1 (949) 355-6244 ext. 198842'
  => '+1 (949) 355-6244 ext. 198842' is a valid phone number.'
  => true

=== In Ruby code

  require 'phone_number_validator'

  check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (949) 355-6244 ext. 198842')

  print check_phone_number

==== Output

  => '+1 (949) 355-6244 ext. 198842' is a valid phone number.'
  => true

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
phone_number_validator-0.3.7 README.rdoc
phone_number_validator-0.3.6 README.rdoc
phone_number_validator-0.3.5 README.rdoc
phone_number_validator-0.3.4 README.rdoc
phone_number_validator-0.3.3 README.rdoc
phone_number_validator-0.3.2 README.rdoc
phone_number_validator-0.3.1 README.rdoc
phone_number_validator-0.3.0 README.rdoc