mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
79017111aa
* new URL parsing, fix #603, fix #541 * AnyUrl parts and more tests * more coverage and db DSNs * remove DSN methods * tests for urlstr * remove debug * make AnyStr a subtype of str * fix with cython * rearranging networking code * allowing international domains, cleanup * support international domains * better URL builder * allow underscores in subdomains and domains * tests for json and schema, max length * urlstr > stricturl * updating docs * tweak docs examples * tweak docs
17 lines
350 B
Python
17 lines
350 B
Python
from pydantic import BaseModel, HttpUrl
|
|
|
|
class MyModel(BaseModel):
|
|
url: HttpUrl
|
|
|
|
m1 = MyModel(url='http://puny£code.com')
|
|
print(m1.url)
|
|
#> http://xn--punycode-eja.com
|
|
print(m1.url.host_type)
|
|
#> int_domain
|
|
|
|
m2 = MyModel(url='https://www.аррӏе.com/')
|
|
print(m2.url)
|
|
#> https://www.xn--80ak6aa92e.com/
|
|
print(m2.url.host_type)
|
|
#> int_domain
|