domain¶
            validators.domain.domain(value, /, *, consider_tld=False, rfc_1034=False, rfc_2782=False)
¶
    Return whether or not given value is a valid domain.
Examples:
>>> domain('example.com')
True
>>> domain('example.com/')
ValidationError(func=domain, args={'value': 'example.com/'})
>>> # Supports IDN domains as well::
>>> domain('xn----gtbspbbmkef.xn--p1ai')
True
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| value | str | Domain string to validate. | required | 
| consider_tld | bool | Restrict domain to TLDs allowed by IANA. | False | 
| rfc_1034 | bool | Allows optional trailing dot in the domain name. Ref: RFC 1034. | False | 
| rfc_2782 | bool | Domain name is of type service record. Allows optional underscores in the domain name. Ref: RFC 2782. | False | 
Returns:
| Type | Description | 
|---|---|
| Literal[True] | If  | 
| ValidationError | If  | 
Raises:
| Type | Description | 
|---|---|
| UnicodeError | If  | 
Source code in src/validators/domain.py
              | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |  |