From 04afaefa471d47959fb941cada7a415550090299 Mon Sep 17 00:00:00 2001 From: Hasan <31344273+ImportErr@users.noreply.github.com> Date: Sun, 25 Nov 2018 09:25:08 +0000 Subject: Add a regex validator to snakename fields. (#151) --- api/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'api/models.py') 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): -- cgit v1.2.3