From 1fa863195da140d15661b177d3f24b4733b5a849 Mon Sep 17 00:00:00 2001 From: fvergaracl Date: Thu, 7 Mar 2024 15:00:42 +0100 Subject: [PATCH] Add slug validation utility function --- app/util/validate_slug.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/util/validate_slug.py diff --git a/app/util/validate_slug.py b/app/util/validate_slug.py new file mode 100644 index 00000000..95539958 --- /dev/null +++ b/app/util/validate_slug.py @@ -0,0 +1,14 @@ +import re + + +def validate_slug(slug): + """ + Validates a slug. + :param slug: The slug to validate. + :type slug: str + :return: True if the slug is valid, False otherwise. + :rtype: bool + + + """ + return re.match(r'^[a-z0-9_-]{3,60}$', slug) is not None