mirror of
https://github.com/django/django.git
synced 2025-12-15 21:45:20 +00:00
Fixed #18119 -- Added a DomainNameValidator validator.
Thanks Claude Paroz for the review. Co-authored-by: Nina Menezes <77671865+nmenezes0@users.noreply.github.com>
This commit is contained in:
parent
b9838c65ec
commit
4971a9afe5
4 changed files with 150 additions and 15 deletions
|
|
@ -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``
|
||||
-----------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue