diff --git a/20230125142000_functions.up.sql b/20230125142000_functions.up.sql index aa3238c..416df33 100644 --- a/20230125142000_functions.up.sql +++ b/20230125142000_functions.up.sql @@ -1,16 +1,13 @@ BEGIN; -CREATE FUNCTION is_name(value TEXT) RETURNS BOOLEAN LANGUAGE plpgsql AS $$ -BEGIN +CREATE FUNCTION is_name(value TEXT) RETURNS BOOLEAN LANGUAGE plpgsql +AS $$BEGIN RETURN value = btrim(value) AND length(value) > 0; -END; -$$; +END$$; CREATE FUNCTION is_language_code(value VARCHAR) RETURNS BOOLEAN LANGUAGE plpgsql -AS $$ -BEGIN +AS $$BEGIN RETURN value ~ '^[a-z]{2}$'; -END; -$$; +END$$; COMMIT;