Coder Social home page Coder Social logo

pg_nanp's Introduction

pg_nanp

an efficient, validated, formatted NANP type

Description

This type supports efficient, validated, formatted usage of North American Numbering Plan (NANP) data. It only accepts valid NANP numeric sequences, rejecting sequences that violate NANP specifications. On the other hand, it supports numerous typical formatting embellishments to plain NANP numeric sequences. It formats output consistently in ###-###-#### format.

Installation

curl -s -S -L https://github.com/rlichtenwalter/pg_nanp/archive/master.zip > pg_nanp.zip
unzip pg_nanp.zip
(cd pg_nanp-master && make PG_CONFIG=<optional custom pg_config path>)
(cd pg_nanp-master && make PG_CONFIG=<optional custom pg_config path> install)
(cd ~postgres && sudo -u postgres psql -c 'CREATE EXTENSION pg_nanp;')

Usage

testuser=# SELECT '2345678910'::nanp;
     nanp
--------------
 234-567-8910
(1 row)

testuser=# SELECT '12345678910'::nanp; nanp -------------- 234-567-8910 (1 row)

testuser=# SELECT '22345678910'::nanp; ERROR: invalid input format for nanp: '22345678910' LINE 1: SELECT '22345678910'::nanp;

testuser=# SELECT '1345678910'::nanp; ERROR: invalid input format for nanp: '1345678910' LINE 1: SELECT '1345678910'::nanp;

testuser=# SELECT '1145678910'::nanp; ERROR: invalid input format for nanp: '1145678910' LINE 1: SELECT '1145678910'::nanp;

testuser=# SELECT '2341678910'::nanp; ERROR: invalid input format for nanp: '2341678910' LINE 1: SELECT '2341678910'::nanp;

pg_nanp's People

Contributors

rlichtenwalter avatar

Stargazers

Georgy Shelkovy avatar

Watchers

 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.