Skip to content

Formats

For usage and examples, see the Formats guide.

Built-in format types for JSON Schema validation.

This module exports Pydantic-compatible types for all formats defined in JSON Schema §7.3. Use them directly in Pydantic models or pass them as formats to SchemaConverter.

UUID

UUID = UUID

UUID value.

Source: RFC 4122

Date

Date = date

Calendar date.

Source: RFC 3339

DateTime

DateTime = datetime

Date-time value.

Source: RFC 3339

Duration

Duration = timedelta

Duration.

Source: RFC 3339, appendix A

Email

Email = Annotated[str, AfterValidator(validate_email)]

Email address.

Source: RFC 5321

Hostname

Hostname = Annotated[str, AfterValidator(validate_hostname)]

Hostname.

Source: RFC 1123

IdnEmail

IdnEmail = Annotated[str, AfterValidator(validate_idn_email)]

Internationalized email address.

Source: RFC 6531

IdnHostname

IdnHostname = Annotated[str, AfterValidator(validate_idn_hostname)]

Internationalized hostname.

Source: RFC 5890

IPv4

IPv4 = IPv4Address

IPv4 address.

Source: RFC 2673, section 3.2

IPv6

IPv6 = IPv6Address

IPv6 address.

Source: RFC 4291, section 2.2

Iri

Iri = Annotated[str, AfterValidator(validate_iri)]

Absolute internationalized URI.

Source: RFC 3987

IriReference

IriReference = Annotated[str, AfterValidator(validate_iri_reference)]

IRI reference, absolute or relative.

Source: RFC 3987

JsonPointer

JsonPointer = Annotated[str, AfterValidator(validate_json_pointer)]

JSON Pointer.

Source: RFC 6901

Regex

Regex = Annotated[str, AfterValidator(validate_regex)]

Regular expression, ECMA-262 dialect.

Source: JSON Schema §7.3.8

RelativeJsonPointer

RelativeJsonPointer = Annotated[
    str, AfterValidator(validate_relative_json_pointer)
]

Relative JSON Pointer.

Source: draft-bhutton-relative-json-pointer-00

Time

Time = time

Time value.

Source: RFC 3339

Uri

Uri = Annotated[str, AfterValidator(validate_uri)]

Absolute URI with a scheme.

Source: RFC 3986

UriReference

UriReference = Annotated[str, AfterValidator(validate_uri_reference)]

URI reference, absolute or relative.

Source: RFC 3986, section 4.1

UriTemplate

UriTemplate = Annotated[str, AfterValidator(validate_uri_template)]

URI Template.

Source: RFC 6570