Phone Number Validation in postgres

I took a simple number validation code across net and modified it to check phone numbers. It allows only numbers,plus symbol(+) and underscore(_) operators

-- Function: isphoneno(character varying)

-- DROP FUNCTION isphoneno(character varying);

CREATE OR REPLACE FUNCTION isphoneno(character varying)
  RETURNS boolean AS
$BODY$
BEGIN
    RETURN $1 ~ '^[0-9,+,-,.]+$';
END;
$BODY$
  LANGUAGE 'plpgsql' IMMUTABLE
  COST 100;
ALTER FUNCTION isphoneno(character varying) OWNER TO tad;

Comments

Popular posts from this blog

Changing Timezone in Postgresql, Ubuntu

Display Logic and read only logic In Openbravo

My 10 years in Application Development