Web¶
Validated types for web standards: authentication tokens, MIME types, hashes, and network identifiers.
Modules:
-
auth–Validated types for HTTP authentication headers.
-
hash–Cryptographic hash hex digest types.
-
jwt–JSON Web Token (JWT) type with parsed header and payload.
-
mime–MIME type with parsed components.
-
network–Validated types for network identifiers.
-
slug–Validated type for URL slugs.
-
urn–Validated type for Uniform Resource Names (URNs).
Classes:
-
BearerToken–A Bearer token string like 'Bearer
' with the extracted token value. -
Fqdn–A fully qualified domain name like www.example.com with parsed labels.
-
Host–A network host (domain name, IPv4, or bracketed IPv6) with a host_type property.
-
Jwt–A JSON Web Token (JWT) string with parsed header and payload.
-
MimeType–A MIME type like application/json or text/html;charset=utf-8.
-
PortRange–A TCP/UDP port or port range like 443 or 8080-8090 with parsed endpoints.
-
Urn–A Uniform Resource Name like urn:isbn:0451450523 with parsed NID and NSS.
Attributes:
-
Md5Hex–An MD5 hex digest (32 hex characters, normalized to lowercase) (e.g.
d41d8cd98f00b204e9800998ecf8427e). -
Sha1Hex–A SHA-1 hex digest (40 hex characters, normalized to lowercase) (e.g.
da39a3ee5e6b4b0d3255bfef95601890afd80709). -
Sha256Hex–A SHA-256 hex digest (64 hex characters, normalized to lowercase) (e.g.
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855). -
Slug–A URL-friendly slug: lowercase alphanumeric with hyphens (e.g.
my-blog-post).
Md5Hex
module-attribute
¶
Md5Hex = Annotated[str, AfterValidator(_validate_md5_hex), WithJsonSchema({'type': 'string', 'format': 'md5-hex', 'pattern': '^[0-9a-fA-F]{32}$', 'description': 'An MD5 hex digest (32 hex characters, normalized to lowercase)', 'examples': ['d41d8cd98f00b204e9800998ecf8427e'], 'title': 'Md5Hex', 'minLength': 32, 'maxLength': 32})]
An MD5 hex digest (32 hex characters, normalized to lowercase) (e.g. d41d8cd98f00b204e9800998ecf8427e).
Sha1Hex
module-attribute
¶
Sha1Hex = Annotated[str, AfterValidator(_validate_sha1_hex), WithJsonSchema({'type': 'string', 'format': 'sha1-hex', 'pattern': '^[0-9a-fA-F]{40}$', 'description': 'A SHA-1 hex digest (40 hex characters, normalized to lowercase)', 'examples': ['da39a3ee5e6b4b0d3255bfef95601890afd80709'], 'title': 'Sha1Hex', 'minLength': 40, 'maxLength': 40})]
A SHA-1 hex digest (40 hex characters, normalized to lowercase) (e.g. da39a3ee5e6b4b0d3255bfef95601890afd80709).
Sha256Hex
module-attribute
¶
Sha256Hex = Annotated[str, AfterValidator(_validate_sha256_hex), WithJsonSchema({'type': 'string', 'format': 'sha256-hex', 'pattern': '^[0-9a-fA-F]{64}$', 'description': 'A SHA-256 hex digest (64 hex characters, normalized to lowercase)', 'examples': ['e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'], 'title': 'Sha256Hex', 'minLength': 64, 'maxLength': 64})]
A SHA-256 hex digest (64 hex characters, normalized to lowercase) (e.g. e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855).
Slug
module-attribute
¶
Slug = Annotated[str, AfterValidator(_validate_slug), WithJsonSchema({'type': 'string', 'pattern': '^[a-z0-9]+(-[a-z0-9]+)*$', 'description': 'A URL-friendly slug: lowercase alphanumeric with hyphens', 'examples': ['my-blog-post', 'hello-world', 'pydantic-types-101'], 'title': 'Slug', 'maxLength': 128})]
A URL-friendly slug: lowercase alphanumeric with hyphens (e.g. my-blog-post).
BearerToken
¶
Bases: str
A Bearer token string like 'Bearer
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for BearerToken.
-
__get_pydantic_json_schema__–Return the JSON schema for BearerToken.
-
__new__–Create and validate a new BearerToken instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for BearerToken.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for BearerToken.
Source code in src/pydantypes/web/auth.py
__new__
¶
__new__(value: str) -> BearerToken
Create and validate a new BearerToken instance.
Source code in src/pydantypes/web/auth.py
Fqdn
¶
Bases: str
A fully qualified domain name like www.example.com with parsed labels.
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for Fqdn.
-
__get_pydantic_json_schema__–Return the JSON schema for Fqdn.
-
__new__–Create and validate a new Fqdn instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for Fqdn.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for Fqdn.
Source code in src/pydantypes/web/network.py
__new__
¶
__new__(value: str) -> Fqdn
Create and validate a new Fqdn instance.
Source code in src/pydantypes/web/network.py
Host
¶
Bases: str
A network host (domain name, IPv4, or bracketed IPv6) with a host_type property.
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for Host.
-
__get_pydantic_json_schema__–Return the JSON schema for Host.
-
__new__–Create and validate a new Host instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for Host.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for Host.
Source code in src/pydantypes/web/network.py
__new__
¶
__new__(value: str) -> Host
Create and validate a new Host instance.
Source code in src/pydantypes/web/network.py
Jwt
¶
Bases: str
A JSON Web Token (JWT) string with parsed header and payload.
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for Jwt.
-
__get_pydantic_json_schema__–Return the JSON schema for Jwt.
-
__new__–Create and validate a new Jwt instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for Jwt.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for Jwt.
Source code in src/pydantypes/web/jwt.py
__new__
¶
__new__(value: str) -> Jwt
Create and validate a new Jwt instance.
Source code in src/pydantypes/web/jwt.py
MimeType
¶
Bases: str
A MIME type like application/json or text/html;charset=utf-8.
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for MimeType.
-
__get_pydantic_json_schema__–Return the JSON schema for MimeType.
-
__new__–Create and validate a new MimeType instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for MimeType.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for MimeType.
Source code in src/pydantypes/web/mime.py
__new__
¶
__new__(value: str) -> MimeType
Create and validate a new MimeType instance.
Source code in src/pydantypes/web/mime.py
PortRange
¶
Bases: str
A TCP/UDP port or port range like 443 or 8080-8090 with parsed endpoints.
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for PortRange.
-
__get_pydantic_json_schema__–Return the JSON schema for PortRange.
-
__new__–Create and validate a new PortRange instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for PortRange.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for PortRange.
Source code in src/pydantypes/web/network.py
__new__
¶
__new__(value: str) -> PortRange
Create and validate a new PortRange instance.
Source code in src/pydantypes/web/network.py
Urn
¶
Bases: str
A Uniform Resource Name like urn:isbn:0451450523 with parsed NID and NSS.
Methods:
-
__get_pydantic_core_schema__–Return the Pydantic core schema for Urn.
-
__get_pydantic_json_schema__–Return the JSON schema for Urn.
-
__new__–Create and validate a new Urn instance.
__get_pydantic_core_schema__
classmethod
¶
Return the Pydantic core schema for Urn.
__get_pydantic_json_schema__
classmethod
¶
__get_pydantic_json_schema__(_core_schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue
Return the JSON schema for Urn.
Source code in src/pydantypes/web/urn.py
__new__
¶
__new__(value: str) -> Urn
Create and validate a new Urn instance.