domain¶
validators.domain.domain(value, /, *, rfc_1034=False, rfc_2782=False)
¶
Return whether or not given value is a valid domain.
Examples:
>>> domain('example.com')
# Output: True
>>> domain('example.com/')
# Output: ValidationError(func=domain, ...)
>>> # Supports IDN domains as well::
>>> domain('xn----gtbspbbmkef.xn--p1ai')
# Output: True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Domain string to validate. |
required |
rfc_1034 |
bool
|
Allow trailing dot in domain name. Ref: RFC 1034. |
False
|
rfc_2782 |
bool
|
Domain name is of type service record. Ref: RFC 2782. |
False
|
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Note
- In version 0.10.0:
- Added support for internationalized domain name (IDN) validation.
New in version 0.9.0.
Source code in /opt/hostedtoolcache/Python/3.11.7/x64/lib/python3.11/site-packages/validators/domain.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|