1
0
Fork 0
database/20230125142000_functions.up.sql

14 lines
292 B
MySQL
Raw Normal View History

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