diff options
| author | Berker Peksag <berker.peksag@gmail.com> | 2016-09-27 04:59:48 +0300 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-05-21 23:11:12 +0200 |
| commit | 4971a9afe5642569f3dcfcd3972ebb39e88dd457 (patch) | |
| tree | 56248ceac38e90d6523045eef5c47182dd2f3fa1 /docs | |
| parent | b9838c65ec2fee36c1fd0d46494ba44da27a9b34 (diff) | |
Fixed #18119 -- Added a DomainNameValidator validator.
Thanks Claude Paroz for the review.
Co-authored-by: Nina Menezes <77671865+nmenezes0@users.noreply.github.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/validators.txt | 28 | ||||
| -rw-r--r-- | docs/releases/5.1.txt | 5 |
2 files changed, 32 insertions, 1 deletions
diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index fb69ec8d33..3287d0560e 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -159,6 +159,25 @@ to, or in lieu of custom ``field.clean()`` methods. validation, so you'd need to add them to the ``allowlist`` as necessary. +``DomainNameValidator`` +----------------------- + +.. versionadded:: 5.1 + +.. class:: DomainNameValidator(accept_idna=True, message=None, code=None) + + A :class:`RegexValidator` subclass that ensures a value looks like a domain + name. Values longer than 255 characters are always considered invalid. IP + addresses are not accepted as valid domain names. + + In addition to the optional arguments of its parent :class:`RegexValidator` + class, ``DomainNameValidator`` accepts an extra optional attribute: + + .. attribute:: accept_idna + + Determines whether to accept internationalized domain names, that is, + domain names that contain non-ASCII characters. Defaults to ``True``. + ``URLValidator`` ---------------- @@ -201,6 +220,15 @@ to, or in lieu of custom ``field.clean()`` methods. An :class:`EmailValidator` instance without any customizations. +``validate_domain_name`` +------------------------ + +.. versionadded:: 5.1 + +.. data:: validate_domain_name + + A :class:`DomainNameValidator` instance without any customizations. + ``validate_slug`` ----------------- diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index bb5e4f3fe4..d846788815 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -363,7 +363,10 @@ Utilities Validators ~~~~~~~~~~ -* ... +* The new :class:`~django.core.validators.DomainNameValidator` validates domain + names, including internationalized domain names. The new + :func:`~django.core.validators.validate_domain_name` function returns an + instance of :class:`~django.core.validators.DomainNameValidator`. .. _backwards-incompatible-5.1: |
