vadviktor
8/30/2012 - 4:26 PM

Postgresql domains

Postgresql domains

CREATE DOMAIN sha1_hexa_40 AS character(40) CONSTRAINT sha1_hexa_40_check CHECK ((VALUE ~* ('[a-f,0-9]{40}'::character(40))::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 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));