Skip to content

stevepiercy/valid_nanp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

valid_nanp - Validate phone numbers according to the North American Numbering Plan

Read the article valid_nanp - Validate phone numbers according to the North American Numbering Plan.

Description

[valid_nanp] determines whether a string contains a valid phone number according to the North American Numbering Plan. Validation ignores all non-numeric characters. Additionally the number must have at least 10 digits and cannot begin with +1. Phone numbers with extensions are permitted, where any digit beyond the first 10 digits forms the extension. Optionally formats the output, substituting # for digits, and inserting any other arbitrary character.

[valid_nanp] has versions available for either Lasso 8 or Lasso 9.

Demo

Demo.

Usage

valid_nanp accepts two parameters.

-number is required and must be a string type. This is the phone number to be validated and optionally formatted.

-format is optional and must be a string type. This is the output format.

Examples

valid_nanp('631-960-7187');
=> true
valid_nanp('401-285-0696', -format='(###) ###-#### x######');
=> (401) 285-0696
valid_nanp('oogahboogah401oopsie-285-0696ext12345', -format='(###) ###-#### x######');
=> (401) 285-0696 x12345

Installation

The repository contains both the tag [valid_nanp] in a file named valid_nanp.lasso and a directory valid_nanp_demo containing the demo. In this directory there is a web page named index.lasso containing the valid_nanp tag and a web form.

About

Determines whether a string contains a valid phone number according to the North American Numbering Plan

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages