#24373: RegexValidator In ArrayField Not Running
----------------------------------+---------------------------------------
Reporter: DavidMuller | Owner:
Type: Uncategorized | Status: new
Component: contrib.postgres | Version: 1.8alpha1
Severity: Normal | Keywords: ArrayField RegexValidator
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+---------------------------------------
I am trying out Django 1.8's new ArrayField and was hoping to enforce
RegexValidation on an array of CharFields. It appears, however, that the
RegexValidator is not being run.
For the sake of simplicity, let's say I only wanted to accept numeric
values in my CharFields. We'll also say that my save() method calls
full_clean():
{{{
class TestModel(models.Model):
names = ArrayField(
models.CharField(max_length=100, blank=False,
validators=[RegexValidator(r'^[0-9]*$')]),
)
def save(self, *args, **kwargs):
"""
Raise ValidationError if a field doesn't pass validation.
"""
try:
self.full_clean()
except ValidationError:
raise
super(TestModel, self).save(*args, **kwargs)
}}}
No ValidationError is thrown, a TestModel record is created successfully:
{{{
In [2]: TestModel.objects.create(names=['no'])
Out[2]: <TestModel: TestModel object>
}}}
Is not possible to add validators to the <base_field> of my ArrayField?
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/24373>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.c0dde56fbc5a4a34938f0bec574451e5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.