Sha256: 363ec6b5756eb98379a8e15e8b27b730caeecc62b64e92e5931a513747ba89b1

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 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

=== Updating Required Gems/Dependencies

  $ bundle update

== Uninstalling

  $ gem uninstall phone_number_validator

== Testing

  $ rake test

== Usage

=== In command line

  $ pnv "+1 (987) 654-3210 ext. 198842"

==== Output

  => true

=== In Ruby code

  require 'phone_number_validator'

  check_phone_number = PhoneNumberValidator.validate_phone_number('+1 (987) 654-3210 ext. 198842')

  print check_phone_number

==== Output

  => true

=== Output Types

Output can be:
* <b>true</b> (<em>boolean: valid phone number</em>)
* <b>false</b> (<em>boolean: invalid phone number</em>)
* <b>nil</b> (<em>nil: no phone number entered</em>)
* <b>void</b> (<em>void: no phone number arg provided</em>)

== Development

Run the following in development to make +bin/pnv+ executable (Unix only):

    chmod ugo+x bin/pnv

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
phone_number_validator-1.0.3 README.rdoc
phone_number_validator-1.0.2 README.rdoc
phone_number_validator-1.0.1 README.rdoc
phone_number_validator-1.0.0 README.rdoc
phone_number_validator-0.9.9 README.rdoc
phone_number_validator-0.9.8 README.rdoc
phone_number_validator-0.9.7 README.rdoc
phone_number_validator-0.9.6 README.rdoc
phone_number_validator-0.9.5 README.rdoc