I want to add few identical constraints to 2 tables (on multiple columns).
To this end I want to create functions to be used in check constraint.
The validation should fail if the value contains any of the following (the string will always contain at least some letters):
..(two consequent dots)><- more, than 3 consecutive capital letters
- all letters are capital (must contain at least 1 lowercased letter)
So far I have the following:
CREATE FUNCTION no_forbidden_characters(text) RETURNS boolean
LANGUAGE sql IMMUTABLE STRICT
AS $_$
SELECT $1 !~ '[a-z]+|..|>|<';
$_$;
Not sure how to get the max 3 capital letters in a row (though allowing for multiple separate by a space 3 capital letter combinations)