2023-01-25 10:27:20 -05:00
|
|
|
BEGIN;
|
|
|
|
|
2023-01-25 11:10:19 -05:00
|
|
|
CREATE FUNCTION is_name(value TEXT)
|
|
|
|
RETURNS BOOLEAN
|
|
|
|
IMMUTABLE
|
|
|
|
PARALLEL SAFE
|
|
|
|
LANGUAGE plpgsql
|
2023-01-25 10:46:16 -05:00
|
|
|
AS $$BEGIN
|
2023-01-25 11:10:19 -05:00
|
|
|
RETURN value IS NOT NULL AND value = btrim(value) AND length(value) > 0;
|
2023-01-25 10:46:16 -05:00
|
|
|
END$$;
|
2023-01-25 10:27:20 -05:00
|
|
|
|
2023-01-25 11:10:19 -05:00
|
|
|
CREATE FUNCTION is_language_code(value VARCHAR)
|
|
|
|
RETURNS BOOLEAN
|
|
|
|
IMMUTABLE
|
|
|
|
PARALLEL SAFE
|
|
|
|
LANGUAGE plpgsql
|
2023-01-25 10:46:16 -05:00
|
|
|
AS $$BEGIN
|
2023-01-25 11:10:19 -05:00
|
|
|
RETURN value IS NOT NULL AND value ~ '^[a-z]{2}$';
|
2023-01-25 10:46:16 -05:00
|
|
|
END$$;
|
2023-01-25 10:27:20 -05:00
|
|
|
|
|
|
|
COMMIT;
|