Skip to content

Instantly share code, notes, and snippets.

@vadviktor
Created August 30, 2012 16:26
Show Gist options
  • Save vadviktor/3532358 to your computer and use it in GitHub Desktop.
Save vadviktor/3532358 to your computer and use it in GitHub Desktop.
Postgresql domains
CREATE DOMAIN color_hexa AS character varying(7) DEFAULT NULL::character varying CONSTRAINT color_hexa_check CHECK (((VALUE)::text ~ '^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?'::text));
CREATE DOMAIN e_mail_address AS text CONSTRAINT e_mail_address_check CHECK ((VALUE ~ '^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+[.]{1}([a-zA-Z]{2,4})$'::text));
CREATE DOMAIN sha1_hexa_40 AS character(40) CONSTRAINT sha1_hexa_40_check CHECK ((VALUE ~* ('[a-f,0-9]{40}'::character(40))::text));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment