aboutsummaryrefslogtreecommitdiffstats
path: root/api/models.py
diff options
context:
space:
mode:
authorGravatar Hasan <[email protected]>2018-11-25 09:25:08 +0000
committerGravatar Johannes Christ <[email protected]>2018-11-25 10:25:08 +0100
commit04afaefa471d47959fb941cada7a415550090299 (patch)
treeffc8dff6d7318118060953bbac2d40c28dfb6587 /api/models.py
parentUse `ERROR` log level in tests if no log level is explicitly set. (diff)
Add a regex validator to snakename fields. (#151)
Diffstat (limited to 'api/models.py')
-rw-r--r--api/models.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/api/models.py b/api/models.py
index bcf4af78..7623c86c 100644
--- a/api/models.py
+++ b/api/models.py
@@ -92,11 +92,13 @@ class SnakeName(ModelReprMixin, models.Model):
name = models.CharField(
primary_key=True,
max_length=100,
- help_text="The regular name for this snake, e.g. 'Python'."
+ help_text="The regular name for this snake, e.g. 'Python'.",
+ validators=[RegexValidator(regex=r'^([^0-9])+$')]
)
scientific = models.CharField(
max_length=150,
- help_text="The scientific name for this snake, e.g. 'Python bivittatus'."
+ help_text="The scientific name for this snake, e.g. 'Python bivittatus'.",
+ validators=[RegexValidator(regex=r'^([^0-9])+$')]
)
def __str__(self):