aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-08-04 12:20:52 +0200
committerGravatar Numerlor <[email protected]>2020-08-04 12:20:52 +0200
commitb242f6d4893dd47c8f07df7dd7bf97f8f1c6631c (patch)
tree766833e093e810b3104273a0935b0ece7b977350 /pydis_site/apps/api
parentAdd ascii digits to the validator. (diff)
Move package name validator definition.
The move prevents it going through the line limit and deeper nesting of parentheses from splitting up the string.
Diffstat (limited to 'pydis_site/apps/api')
-rw-r--r--pydis_site/apps/api/models/bot/documentation_link.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/pydis_site/apps/api/models/bot/documentation_link.py b/pydis_site/apps/api/models/bot/documentation_link.py
index e093af59..56b47ae6 100644
--- a/pydis_site/apps/api/models/bot/documentation_link.py
+++ b/pydis_site/apps/api/models/bot/documentation_link.py
@@ -3,6 +3,11 @@ from django.db import models
from pydis_site.apps.api.models.mixins import ModelReprMixin
+package_name_validator = RegexValidator(
+ regex=r"^[a-z0-9_]+$",
+ message="Package names can only consist of lowercase a-z letters, digits, and underscores."
+)
+
class DocumentationLink(ModelReprMixin, models.Model):
"""A documentation link used by the `!docs` command of the bot."""
@@ -10,12 +15,7 @@ class DocumentationLink(ModelReprMixin, models.Model):
package = models.CharField(
primary_key=True,
max_length=50,
- validators=(
- RegexValidator(
- regex=r"^[a-z0-9_]+$",
- message="Package names can only consist of lowercase a-z letters, digits, and underscores."
- ),
- ),
+ validators=package_name_validator,
help_text="The Python package name that this documentation link belongs to."
)
base_url = models.URLField(