Does django supports dynamic allowlist in EmailValidator

118 views
Skip to first unread message

Sencer Hamarat

unread,
Jun 14, 2022, 9:17:40 AM6/14/22
to django...@googlegroups.com
Hi,

Say, I have an email field in a model and need to add an email validator for email domain validation.
For this, allowlist property needs to be append to email validator like:

email = models.EmailField(
    validators=[
        EmailValidator(allowlist=['example1.com', 'example2.com',...])
    ]
)

Can I dynamically fetch domains from another model and assign to allowlist?
"allowlist" must be altered instantly if related domain list model records are changed.

Regards,
Sencer HAMARAT

Sebastian Jung

unread,
Jun 14, 2022, 9:27:29 AM6/14/22
to django...@googlegroups.com
Hello,

You can create a new validator where domains are validate and insert it as second validator.

Regards

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACp8TZgUP9PFB4Rgbhc2sPBvUZ56fy-HFB5AuAxCs8bejo-ahQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages