21 lines
421 B
PL/PgSQL
21 lines
421 B
PL/PgSQL
BEGIN;
|
|
|
|
CREATE FUNCTION is_sane_text(value TEXT)
|
|
RETURNS BOOLEAN
|
|
IMMUTABLE
|
|
PARALLEL SAFE
|
|
LANGUAGE plpgsql
|
|
AS $$BEGIN
|
|
RETURN value IS NOT NULL AND value = btrim(value) AND length(value) > 0;
|
|
END$$;
|
|
|
|
CREATE FUNCTION is_language_code(value VARCHAR)
|
|
RETURNS BOOLEAN
|
|
IMMUTABLE
|
|
PARALLEL SAFE
|
|
LANGUAGE plpgsql
|
|
AS $$BEGIN
|
|
RETURN value IS NOT NULL AND value ~ '^[a-z]{2}$';
|
|
END$$;
|
|
|
|
COMMIT;
|