Skip to content

Instantly share code, notes, and snippets.

@feloy
Created January 19, 2017 09:39
Show Gist options
  • Save feloy/c89a1fb15eb474dd448d3968ffa67db0 to your computer and use it in GitHub Desktop.
Save feloy/c89a1fb15eb474dd448d3968ffa67db0 to your computer and use it in GitHub Desktop.
Valid password for CNIL (France): at least 8 characters from 3 of the 4 groups: lowercase letters, uppercase letters, digits, other characters
CREATE DOMAIN valid_password
AS text
CHECK(7 < char_length(VALUE)
AND 2 < char_length( COALESCE(substring(VALUE from '[^a-zA-Z0-9]'), '')
|| COALESCE(substring(VALUE from '[0-9]'), '')
|| COALESCE(substring(VALUE from '[A-Z]'), '')
|| COALESCE(substring(VALUE from '[a-z]'), '')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment