diff options
author | 2018-11-29 19:10:39 +0000 | |
---|---|---|
committer | 2018-11-29 20:10:39 +0100 | |
commit | 59c45ee43e10737f6aa48ef929b56b176886d0bf (patch) | |
tree | accb3567c1866f09599bd077f5cfb4b7fee7cf27 /api | |
parent | Set up image pushing and building on Azure. (#152) (diff) |
Added regex validator to special snake name. (#153)
Diffstat (limited to 'api')
-rw-r--r-- | api/migrations/0021_add_special_snake_validator.py | 19 | ||||
-rw-r--r-- | api/models.py | 3 |
2 files changed, 21 insertions, 1 deletions
diff --git a/api/migrations/0021_add_special_snake_validator.py b/api/migrations/0021_add_special_snake_validator.py new file mode 100644 index 00000000..d41b96e5 --- /dev/null +++ b/api/migrations/0021_add_special_snake_validator.py @@ -0,0 +1,19 @@ +# Generated by Django 2.1.2 on 2018-11-25 14:59 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0020_add_snake_field_validators'), + ] + + operations = [ + migrations.AlterField( + model_name='specialsnake', + name='name', + field=models.CharField(help_text='A special snake name.', max_length=140, primary_key=True, serialize=False, validators=[django.core.validators.RegexValidator(regex='^([^0-9])+$')]), + ), + ] diff --git a/api/models.py b/api/models.py index 7623c86c..c67f558d 100644 --- a/api/models.py +++ b/api/models.py @@ -111,7 +111,8 @@ class SpecialSnake(ModelReprMixin, models.Model): name = models.CharField( max_length=140, primary_key=True, - help_text='A special snake name.' + help_text='A special snake name.', + validators=[RegexValidator(regex=r'^([^0-9])+$')] ) info = models.TextField( help_text='Info about a special snake.' |