Unofficial research mirror of the Pydantic documentation (MIT licence) for an academic study. Some details differ from the official documentation, so do not rely on this site for real projects. Official docs: docs.pydantic.dev. About this study.

Conversion Table

The following table provides details on how Pydantic converts data during validation in both strict and lax modes.

The "Strict" column contains checkmarks for type conversions that are allowed when validating in Strict Mode.

Field Type Input Strict Input Source Conditions
bool bool ✓ Python & JSON
bool bytes Python Same allowed values as for str. Assumes UTF-8.
bool float Python & JSON Allowed values: 0.0, 1.0.
bool int Python & JSON Allowed values: 0, 1.
bool str Python & JSON Case-insensitive. Allowed values: '0', 'off', 'f', 'false', 'n', 'no', '1', 'on', 't', 'true', 'y', 'yes'.
bool Decimal Python Allowed values: Decimal(0), Decimal(1).
bytes bytearray Python
bytes bytes ✓ Python
bytes str ✓ JSON Decoded according to the val_json_bytes setting (UTF-8 by default).
bytes str Python Decoded according to the val_json_bytes setting (UTF-8 by default).
callable - JSON Never valid.
callable Any ✓ Python callable() check must return True.
complex complex ✓ Python
complex float Python & JSON
complex int Python & JSON
complex str ✓ JSON Must be a valid complex string, e.g. 1+2j.
complex str Python Must be a valid complex string, e.g. 1+2j.
complex Decimal Python
date bytes Python Format: YYYY-MM-DD, a datetime with a zero time component, or a unix timestamp. Must be exact date. See speedate. Assumes UTF-8.
date date ✓ Python
date datetime Python Must be exact date, eg. no H, M, S, f.
date float Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
date int Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
date str ✓ JSON Format: YYYY-MM-DD, or a unix timestamp. Must be exact date.
date str Python & JSON Format: YYYY-MM-DD, a datetime with a zero time component, or a unix timestamp. Must be exact date. See speedate.
date Decimal Python Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
datetime bytes Python Format: YYYY-MM-DDTHH:MM:SS.f, YYYY-MM-DD, or a unix timestamp. See speedate. Assumes UTF-8.
datetime date Python
datetime datetime ✓ Python
datetime float Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
datetime int Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
datetime str ✓ JSON Format: YYYY-MM-DDTHH:MM:SS.f, or a unix timestamp. See speedate.
datetime str Python & JSON Format: YYYY-MM-DDTHH:MM:SS.f, YYYY-MM-DD, or a unix timestamp. See speedate.
datetime Decimal Python Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
deque deque ✓ Python
deque frozenset Python
deque list Python
deque set Python
deque tuple Python
deque Array ✓ JSON
deque Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
dict dict ✓ Python
dict Mapping Python Must implement the mapping interface and have an items() method.
dict Object ✓ JSON
float bool Python & JSON
float bytes Python Must be a valid float, e.g. 3.141, 1e3 or inf. Leading and trailing whitespace and underscores are allowed. Assumes UTF-8.
float float ✓ Python & JSON bool is explicitly forbidden.
float int ✓ Python & JSON
float str Python & JSON Must be a valid float, e.g. 3.141, 1e3 or inf. Leading and trailing whitespace and underscores are allowed.
float Any ✓ Python Must implement __float__() or __index__().
float Decimal ✓ Python
float Fraction ✓ Python
frozendict dict Python frozendict is only available in Python 3.15 and above.
frozendict frozendict ✓ Python frozendict is only available in Python 3.15 and above.
frozendict Mapping Python frozendict is only available in Python 3.15 and above. The input must implement the mapping interface and have an items() method.
frozendict Object ✓ JSON frozendict is only available in Python 3.15 and above.
frozenset deque Python
frozenset dict_keys Python
frozenset dict_values Python
frozenset frozenset ✓ Python
frozenset list Python
frozenset set Python
frozenset tuple Python
frozenset Array ✓ JSON
frozenset Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
int bool Python & JSON
int bytes Python Must be a valid integer, e.g. 123. Leading and trailing whitespace, underscores and a zero fractional part (e.g. 1.0) are allowed. Assumes UTF-8.
int float Python & JSON Must be exact int, e.g. val % 1 == 0, raises error for nan, inf.
int int ✓ Python & JSON bool is explicitly forbidden.
int str Python & JSON Must be a valid integer, e.g. 123. Leading and trailing whitespace, underscores and a zero fractional part (e.g. 1.0) are allowed.
int Decimal Python Must be exact int, e.g. val % 1 == 0.
int Enum Python Uses the value of the enum member.
int Fraction Python Must be exact int, e.g. val % 1 == 0.
list deque Python
list dict_keys Python
list dict_values Python
list frozenset Python
list list ✓ Python
list set Python
list tuple Python
list Array ✓ JSON
list Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
namedtuple dict ✓ Python
namedtuple list ✓ Python
namedtuple namedtuple ✓ Python
namedtuple tuple ✓ Python
namedtuple Array ✓ JSON
namedtuple Iterable ✓ Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
namedtuple Mapping ✓ Python Must implement the mapping interface and have an items() method.
namedtuple NamedTuple ✓ Python
namedtuple Object ✓ JSON
set deque Python
set dict_keys Python
set dict_values Python
set frozenset Python
set list Python
set set ✓ Python
set tuple Python
set Array ✓ JSON
set Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
str bytearray Python Assumes UTF-8, error on unicode decoding error.
str bytes Python Assumes UTF-8, error on unicode decoding error.
str float Python & JSON Only if coerce_numbers_to_str is enabled.
str int Python & JSON Only if coerce_numbers_to_str is enabled.
str str ✓ Python & JSON
str Decimal Python Only if coerce_numbers_to_str is enabled.
str Enum Python Uses the value of the enum member.
time bytes Python Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate. Assumes UTF-8.
time float Python & JSON Interpreted as seconds, range 0 - 86399.9*.
time int Python & JSON Interpreted as seconds, range 0 - 86399.
time str ✓ JSON Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate.
time str Python & JSON Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate.
time time ✓ Python
time Decimal Python Interpreted as seconds, range 0 - 86399.9*.
timedelta bytes Python Format: ISO8601. See speedate, (UTF-8).
timedelta float Python & JSON Interpreted as seconds.
timedelta int Python & JSON Interpreted as seconds.
timedelta str ✓ JSON Format: ISO8601. See speedate.
timedelta str Python & JSON Format: ISO8601. See speedate.
timedelta timedelta ✓ Python
timedelta Decimal Python Interpreted as seconds.
tuple deque Python
tuple dict_keys Python
tuple dict_values Python
tuple frozenset Python
tuple list Python
tuple set Python
tuple tuple ✓ Python
tuple Array ✓ JSON
tuple Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
type - JSON Never valid.
type type ✓ Python
Any Any ✓ Python & JSON
ByteSize float Python & JSON Must be exact int, e.g. val % 1 == 0.
ByteSize int ✓ Python & JSON
ByteSize str ✓ Python & JSON
ByteSize Decimal Python Must be exact int, e.g. val % 1 == 0.
Counter dict Python
Counter Counter ✓ Python
Counter Mapping Python Must implement the mapping interface and have an items() method.
Counter Object ✓ JSON
Decimal float ✓ JSON
Decimal float Python & JSON
Decimal int ✓ JSON
Decimal int Python & JSON
Decimal str ✓ JSON
Decimal str Python & JSON Must be a valid decimal, e.g. 3.141 or 1e3. Leading and trailing whitespace and underscores are allowed.
Decimal tuple Python Decimal tuple form, e.g. (0, (1, 4, 1), -2).
Decimal Decimal ✓ Python
Enum Any ✓ JSON Input value must be convertible to enum values.
Enum Any Python Input value must be convertible to enum values.
Enum Enum ✓ Python
Fraction float ✓ JSON
Fraction float Python
Fraction int ✓ JSON
Fraction int Python
Fraction str ✓ JSON Must be a valid fraction, e.g. 1/3 or 0.5.
Fraction str Python Must be a valid fraction, e.g. 1/3 or 0.5.
Fraction Decimal Python
Fraction Fraction ✓ Python
Hashable Any ✓ Python & JSON isinstance() check against Hashable must return True.
IPv4Address bytes Python
IPv4Address int Python & JSON integer representing the IP address, must be less than 2**32
IPv4Address str ✓ JSON
IPv4Address str Python & JSON
IPv4Address IPv4Address ✓ Python
IPv4Address IPv4Interface ✓ Python
IPv4Interface bytes Python
IPv4Interface int Python & JSON integer representing the IP address, must be less than 2**32
IPv4Interface str ✓ JSON
IPv4Interface str Python & JSON
IPv4Interface tuple Python
IPv4Interface IPv4Address Python
IPv4Interface IPv4Interface ✓ Python
IPv4Interface IPv4Network Python
IPv4Network bytes Python
IPv4Network int Python & JSON integer representing the IP network, must be less than 2**32
IPv4Network str ✓ JSON Host bits must be zero.
IPv4Network str Python & JSON Host bits must be zero.
IPv4Network tuple Python Host bits must be zero.
IPv4Network IPv4Address Python
IPv4Network IPv4Interface Python Host bits must be zero.
IPv4Network IPv4Network ✓ Python
IPv6Address bytes Python
IPv6Address int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Address str ✓ JSON
IPv6Address str Python & JSON
IPv6Address IPv6Address ✓ Python
IPv6Address IPv6Interface ✓ Python
IPv6Interface bytes Python
IPv6Interface int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Interface str ✓ JSON
IPv6Interface str Python & JSON
IPv6Interface tuple Python
IPv6Interface IPv6Address Python
IPv6Interface IPv6Interface ✓ Python
IPv6Interface IPv6Network Python
IPv6Network bytes Python
IPv6Network int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Network str ✓ JSON Host bits must be zero.
IPv6Network str Python & JSON Host bits must be zero.
IPv6Network tuple Python Host bits must be zero.
IPv6Network IPv6Address Python
IPv6Network IPv6Interface Python Host bits must be zero.
IPv6Network IPv6Network ✓ Python
InstanceOf Any ✓ JSON Validated as the wrapped type.
InstanceOf Any ✓ Python isinstance() check must return True.
IntEnum Any ✓ JSON Input value must be one of the enum values, without type coercion.
IntEnum Any Python Input value must be convertible to enum values.
IntEnum IntEnum ✓ Python
Iterable Any ✓ Python Any object for which iter() succeeds. Items are validated lazily.
Iterable Array ✓ JSON
Literal Any ✓ Python & JSON Input must be equal to one of the literal values.
NamedTuple dict ✓ Python
NamedTuple list ✓ Python
NamedTuple namedtuple ✓ Python
NamedTuple tuple ✓ Python
NamedTuple Array ✓ JSON
NamedTuple Iterable ✓ Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
NamedTuple Mapping ✓ Python Must implement the mapping interface and have an items() method.
NamedTuple NamedTuple ✓ Python
NamedTuple Object ✓ JSON
None None ✓ Python & JSON
OrderedDict dict Python
OrderedDict Mapping Python Must implement the mapping interface and have an items() method.
OrderedDict Object ✓ JSON
OrderedDict OrderedDict ✓ Python
Path str ✓ JSON
Path str Python
Path Path ✓ Python
Pattern bytes ✓ Python Input must be a valid pattern. Not valid for Pattern[str].
Pattern str ✓ Python & JSON Input must be a valid pattern. Not valid for Pattern[bytes].
Pattern Pattern ✓ Python The pattern type (str or bytes) must match.
Sequence deque Python
Sequence list ✓ Python
Sequence tuple ✓ Python
Sequence Array ✓ JSON
TypedDict dict ✓ Python
TypedDict Mapping Python Must implement the mapping interface and have an items() method.
TypedDict Object ✓ JSON
UUID bytes Python 16 raw bytes, or a UTF-8 encoded UUID string.
UUID str ✓ JSON
UUID str Python
UUID UUID ✓ Python
Field Type Input Strict Input Source Conditions
bool bool ✓ Python & JSON
bool float Python & JSON Allowed values: 0.0, 1.0.
bool int Python & JSON Allowed values: 0, 1.
bool str Python & JSON Case-insensitive. Allowed values: '0', 'off', 'f', 'false', 'n', 'no', '1', 'on', 't', 'true', 'y', 'yes'.
bytes str ✓ JSON Decoded according to the val_json_bytes setting (UTF-8 by default).
callable - JSON Never valid.
complex float Python & JSON
complex int Python & JSON
complex str ✓ JSON Must be a valid complex string, e.g. 1+2j.
date float Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
date int Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
date str ✓ JSON Format: YYYY-MM-DD, or a unix timestamp. Must be exact date.
date str Python & JSON Format: YYYY-MM-DD, a datetime with a zero time component, or a unix timestamp. Must be exact date. See speedate.
datetime float Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
datetime int Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
datetime str ✓ JSON Format: YYYY-MM-DDTHH:MM:SS.f, or a unix timestamp. See speedate.
datetime str Python & JSON Format: YYYY-MM-DDTHH:MM:SS.f, YYYY-MM-DD, or a unix timestamp. See speedate.
deque Array ✓ JSON
dict Object ✓ JSON
float bool Python & JSON
float float ✓ Python & JSON bool is explicitly forbidden.
float int ✓ Python & JSON
float str Python & JSON Must be a valid float, e.g. 3.141, 1e3 or inf. Leading and trailing whitespace and underscores are allowed.
frozendict Object ✓ JSON frozendict is only available in Python 3.15 and above.
frozenset Array ✓ JSON
int bool Python & JSON
int float Python & JSON Must be exact int, e.g. val % 1 == 0, raises error for nan, inf.
int int ✓ Python & JSON bool is explicitly forbidden.
int str Python & JSON Must be a valid integer, e.g. 123. Leading and trailing whitespace, underscores and a zero fractional part (e.g. 1.0) are allowed.
list Array ✓ JSON
namedtuple Array ✓ JSON
namedtuple Object ✓ JSON
set Array ✓ JSON
str float Python & JSON Only if coerce_numbers_to_str is enabled.
str int Python & JSON Only if coerce_numbers_to_str is enabled.
str str ✓ Python & JSON
time float Python & JSON Interpreted as seconds, range 0 - 86399.9*.
time int Python & JSON Interpreted as seconds, range 0 - 86399.
time str ✓ JSON Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate.
time str Python & JSON Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate.
timedelta float Python & JSON Interpreted as seconds.
timedelta int Python & JSON Interpreted as seconds.
timedelta str ✓ JSON Format: ISO8601. See speedate.
timedelta str Python & JSON Format: ISO8601. See speedate.
tuple Array ✓ JSON
type - JSON Never valid.
Any Any ✓ Python & JSON
ByteSize float Python & JSON Must be exact int, e.g. val % 1 == 0.
ByteSize int ✓ Python & JSON
ByteSize str ✓ Python & JSON
Counter Object ✓ JSON
Decimal float ✓ JSON
Decimal float Python & JSON
Decimal int ✓ JSON
Decimal int Python & JSON
Decimal str ✓ JSON
Decimal str Python & JSON Must be a valid decimal, e.g. 3.141 or 1e3. Leading and trailing whitespace and underscores are allowed.
Enum Any ✓ JSON Input value must be convertible to enum values.
Fraction float ✓ JSON
Fraction int ✓ JSON
Fraction str ✓ JSON Must be a valid fraction, e.g. 1/3 or 0.5.
Hashable Any ✓ Python & JSON isinstance() check against Hashable must return True.
IPv4Address int Python & JSON integer representing the IP address, must be less than 2**32
IPv4Address str ✓ JSON
IPv4Address str Python & JSON
IPv4Interface int Python & JSON integer representing the IP address, must be less than 2**32
IPv4Interface str ✓ JSON
IPv4Interface str Python & JSON
IPv4Network int Python & JSON integer representing the IP network, must be less than 2**32
IPv4Network str ✓ JSON Host bits must be zero.
IPv4Network str Python & JSON Host bits must be zero.
IPv6Address int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Address str ✓ JSON
IPv6Address str Python & JSON
IPv6Interface int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Interface str ✓ JSON
IPv6Interface str Python & JSON
IPv6Network int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Network str ✓ JSON Host bits must be zero.
IPv6Network str Python & JSON Host bits must be zero.
InstanceOf Any ✓ JSON Validated as the wrapped type.
IntEnum Any ✓ JSON Input value must be one of the enum values, without type coercion.
Iterable Array ✓ JSON
Literal Any ✓ Python & JSON Input must be equal to one of the literal values.
NamedTuple Array ✓ JSON
NamedTuple Object ✓ JSON
None None ✓ Python & JSON
OrderedDict Object ✓ JSON
Path str ✓ JSON
Pattern str ✓ Python & JSON Input must be a valid pattern. Not valid for Pattern[bytes].
Sequence Array ✓ JSON
TypedDict Object ✓ JSON
UUID str ✓ JSON
Field Type Input Strict Input Source Conditions
bool bool ✓ Python & JSON
bytes str ✓ JSON Decoded according to the val_json_bytes setting (UTF-8 by default).
complex str ✓ JSON Must be a valid complex string, e.g. 1+2j.
date str ✓ JSON Format: YYYY-MM-DD, or a unix timestamp. Must be exact date.
datetime str ✓ JSON Format: YYYY-MM-DDTHH:MM:SS.f, or a unix timestamp. See speedate.
deque Array ✓ JSON
dict Object ✓ JSON
float float ✓ Python & JSON bool is explicitly forbidden.
float int ✓ Python & JSON
frozendict Object ✓ JSON frozendict is only available in Python 3.15 and above.
frozenset Array ✓ JSON
int int ✓ Python & JSON bool is explicitly forbidden.
list Array ✓ JSON
namedtuple Array ✓ JSON
namedtuple Object ✓ JSON
set Array ✓ JSON
str str ✓ Python & JSON
time str ✓ JSON Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate.
timedelta str ✓ JSON Format: ISO8601. See speedate.
tuple Array ✓ JSON
Any Any ✓ Python & JSON
ByteSize int ✓ Python & JSON
ByteSize str ✓ Python & JSON
Counter Object ✓ JSON
Decimal float ✓ JSON
Decimal int ✓ JSON
Decimal str ✓ JSON
Enum Any ✓ JSON Input value must be convertible to enum values.
Fraction float ✓ JSON
Fraction int ✓ JSON
Fraction str ✓ JSON Must be a valid fraction, e.g. 1/3 or 0.5.
Hashable Any ✓ Python & JSON isinstance() check against Hashable must return True.
IPv4Address str ✓ JSON
IPv4Interface str ✓ JSON
IPv4Network str ✓ JSON Host bits must be zero.
IPv6Address str ✓ JSON
IPv6Interface str ✓ JSON
IPv6Network str ✓ JSON Host bits must be zero.
InstanceOf Any ✓ JSON Validated as the wrapped type.
IntEnum Any ✓ JSON Input value must be one of the enum values, without type coercion.
Iterable Array ✓ JSON
Literal Any ✓ Python & JSON Input must be equal to one of the literal values.
NamedTuple Array ✓ JSON
NamedTuple Object ✓ JSON
None None ✓ Python & JSON
OrderedDict Object ✓ JSON
Path str ✓ JSON
Pattern str ✓ Python & JSON Input must be a valid pattern. Not valid for Pattern[bytes].
Sequence Array ✓ JSON
TypedDict Object ✓ JSON
UUID str ✓ JSON
Field Type Input Strict Input Source Conditions
bool bool ✓ Python & JSON
bool bytes Python Same allowed values as for str. Assumes UTF-8.
bool float Python & JSON Allowed values: 0.0, 1.0.
bool int Python & JSON Allowed values: 0, 1.
bool str Python & JSON Case-insensitive. Allowed values: '0', 'off', 'f', 'false', 'n', 'no', '1', 'on', 't', 'true', 'y', 'yes'.
bool Decimal Python Allowed values: Decimal(0), Decimal(1).
bytes bytearray Python
bytes bytes ✓ Python
bytes str Python Decoded according to the val_json_bytes setting (UTF-8 by default).
callable Any ✓ Python callable() check must return True.
complex complex ✓ Python
complex float Python & JSON
complex int Python & JSON
complex str Python Must be a valid complex string, e.g. 1+2j.
complex Decimal Python
date bytes Python Format: YYYY-MM-DD, a datetime with a zero time component, or a unix timestamp. Must be exact date. See speedate. Assumes UTF-8.
date date ✓ Python
date datetime Python Must be exact date, eg. no H, M, S, f.
date float Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
date int Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
date str Python & JSON Format: YYYY-MM-DD, a datetime with a zero time component, or a unix timestamp. Must be exact date. See speedate.
date Decimal Python Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting. Must be exact date.
datetime bytes Python Format: YYYY-MM-DDTHH:MM:SS.f, YYYY-MM-DD, or a unix timestamp. See speedate. Assumes UTF-8.
datetime date Python
datetime datetime ✓ Python
datetime float Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
datetime int Python & JSON Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
datetime str Python & JSON Format: YYYY-MM-DDTHH:MM:SS.f, YYYY-MM-DD, or a unix timestamp. See speedate.
datetime Decimal Python Interpreted as seconds or milliseconds from epoch, depending on the val_temporal_unit setting.
deque deque ✓ Python
deque frozenset Python
deque list Python
deque set Python
deque tuple Python
deque Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
dict dict ✓ Python
dict Mapping Python Must implement the mapping interface and have an items() method.
float bool Python & JSON
float bytes Python Must be a valid float, e.g. 3.141, 1e3 or inf. Leading and trailing whitespace and underscores are allowed. Assumes UTF-8.
float float ✓ Python & JSON bool is explicitly forbidden.
float int ✓ Python & JSON
float str Python & JSON Must be a valid float, e.g. 3.141, 1e3 or inf. Leading and trailing whitespace and underscores are allowed.
float Any ✓ Python Must implement __float__() or __index__().
float Decimal ✓ Python
float Fraction ✓ Python
frozendict dict Python frozendict is only available in Python 3.15 and above.
frozendict frozendict ✓ Python frozendict is only available in Python 3.15 and above.
frozendict Mapping Python frozendict is only available in Python 3.15 and above. The input must implement the mapping interface and have an items() method.
frozenset deque Python
frozenset dict_keys Python
frozenset dict_values Python
frozenset frozenset ✓ Python
frozenset list Python
frozenset set Python
frozenset tuple Python
frozenset Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
int bool Python & JSON
int bytes Python Must be a valid integer, e.g. 123. Leading and trailing whitespace, underscores and a zero fractional part (e.g. 1.0) are allowed. Assumes UTF-8.
int float Python & JSON Must be exact int, e.g. val % 1 == 0, raises error for nan, inf.
int int ✓ Python & JSON bool is explicitly forbidden.
int str Python & JSON Must be a valid integer, e.g. 123. Leading and trailing whitespace, underscores and a zero fractional part (e.g. 1.0) are allowed.
int Decimal Python Must be exact int, e.g. val % 1 == 0.
int Enum Python Uses the value of the enum member.
int Fraction Python Must be exact int, e.g. val % 1 == 0.
list deque Python
list dict_keys Python
list dict_values Python
list frozenset Python
list list ✓ Python
list set Python
list tuple Python
list Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
namedtuple dict ✓ Python
namedtuple list ✓ Python
namedtuple namedtuple ✓ Python
namedtuple tuple ✓ Python
namedtuple Iterable ✓ Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
namedtuple Mapping ✓ Python Must implement the mapping interface and have an items() method.
namedtuple NamedTuple ✓ Python
set deque Python
set dict_keys Python
set dict_values Python
set frozenset Python
set list Python
set set ✓ Python
set tuple Python
set Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
str bytearray Python Assumes UTF-8, error on unicode decoding error.
str bytes Python Assumes UTF-8, error on unicode decoding error.
str float Python & JSON Only if coerce_numbers_to_str is enabled.
str int Python & JSON Only if coerce_numbers_to_str is enabled.
str str ✓ Python & JSON
str Decimal Python Only if coerce_numbers_to_str is enabled.
str Enum Python Uses the value of the enum member.
time bytes Python Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate. Assumes UTF-8.
time float Python & JSON Interpreted as seconds, range 0 - 86399.9*.
time int Python & JSON Interpreted as seconds, range 0 - 86399.
time str Python & JSON Format: HH:MM[:SS[.FFFFFF]], with an optional timezone offset. See speedate.
time time ✓ Python
time Decimal Python Interpreted as seconds, range 0 - 86399.9*.
timedelta bytes Python Format: ISO8601. See speedate, (UTF-8).
timedelta float Python & JSON Interpreted as seconds.
timedelta int Python & JSON Interpreted as seconds.
timedelta str Python & JSON Format: ISO8601. See speedate.
timedelta timedelta ✓ Python
timedelta Decimal Python Interpreted as seconds.
tuple deque Python
tuple dict_keys Python
tuple dict_values Python
tuple frozenset Python
tuple list Python
tuple set Python
tuple tuple ✓ Python
tuple Iterable Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
type type ✓ Python
Any Any ✓ Python & JSON
ByteSize float Python & JSON Must be exact int, e.g. val % 1 == 0.
ByteSize int ✓ Python & JSON
ByteSize str ✓ Python & JSON
ByteSize Decimal Python Must be exact int, e.g. val % 1 == 0.
Counter dict Python
Counter Counter ✓ Python
Counter Mapping Python Must implement the mapping interface and have an items() method.
Decimal float Python & JSON
Decimal int Python & JSON
Decimal str Python & JSON Must be a valid decimal, e.g. 3.141 or 1e3. Leading and trailing whitespace and underscores are allowed.
Decimal tuple Python Decimal tuple form, e.g. (0, (1, 4, 1), -2).
Decimal Decimal ✓ Python
Enum Any Python Input value must be convertible to enum values.
Enum Enum ✓ Python
Fraction float Python
Fraction int Python
Fraction str Python Must be a valid fraction, e.g. 1/3 or 0.5.
Fraction Decimal Python
Fraction Fraction ✓ Python
Hashable Any ✓ Python & JSON isinstance() check against Hashable must return True.
IPv4Address bytes Python
IPv4Address int Python & JSON integer representing the IP address, must be less than 2**32
IPv4Address str Python & JSON
IPv4Address IPv4Address ✓ Python
IPv4Address IPv4Interface ✓ Python
IPv4Interface bytes Python
IPv4Interface int Python & JSON integer representing the IP address, must be less than 2**32
IPv4Interface str Python & JSON
IPv4Interface tuple Python
IPv4Interface IPv4Address Python
IPv4Interface IPv4Interface ✓ Python
IPv4Interface IPv4Network Python
IPv4Network bytes Python
IPv4Network int Python & JSON integer representing the IP network, must be less than 2**32
IPv4Network str Python & JSON Host bits must be zero.
IPv4Network tuple Python Host bits must be zero.
IPv4Network IPv4Address Python
IPv4Network IPv4Interface Python Host bits must be zero.
IPv4Network IPv4Network ✓ Python
IPv6Address bytes Python
IPv6Address int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Address str Python & JSON
IPv6Address IPv6Address ✓ Python
IPv6Address IPv6Interface ✓ Python
IPv6Interface bytes Python
IPv6Interface int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Interface str Python & JSON
IPv6Interface tuple Python
IPv6Interface IPv6Address Python
IPv6Interface IPv6Interface ✓ Python
IPv6Interface IPv6Network Python
IPv6Network bytes Python
IPv6Network int Python & JSON integer representing the IP address, must be less than 2**128
IPv6Network str Python & JSON Host bits must be zero.
IPv6Network tuple Python Host bits must be zero.
IPv6Network IPv6Address Python
IPv6Network IPv6Interface Python Host bits must be zero.
IPv6Network IPv6Network ✓ Python
InstanceOf Any ✓ Python isinstance() check must return True.
IntEnum Any Python Input value must be convertible to enum values.
IntEnum IntEnum ✓ Python
Iterable Any ✓ Python Any object for which iter() succeeds. Items are validated lazily.
Literal Any ✓ Python & JSON Input must be equal to one of the literal values.
NamedTuple dict ✓ Python
NamedTuple list ✓ Python
NamedTuple namedtuple ✓ Python
NamedTuple tuple ✓ Python
NamedTuple Iterable ✓ Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
NamedTuple Mapping ✓ Python Must implement the mapping interface and have an items() method.
NamedTuple NamedTuple ✓ Python
None None ✓ Python & JSON
OrderedDict dict Python
OrderedDict Mapping Python Must implement the mapping interface and have an items() method.
OrderedDict OrderedDict ✓ Python
Path str Python
Path Path ✓ Python
Pattern bytes ✓ Python Input must be a valid pattern. Not valid for Pattern[str].
Pattern str ✓ Python & JSON Input must be a valid pattern. Not valid for Pattern[bytes].
Pattern Pattern ✓ Python The pattern type (str or bytes) must match.
Sequence deque Python
Sequence list ✓ Python
Sequence tuple ✓ Python
TypedDict dict ✓ Python
TypedDict Mapping Python Must implement the mapping interface and have an items() method.
UUID bytes Python 16 raw bytes, or a UTF-8 encoded UUID string.
UUID str Python
UUID UUID ✓ Python
Field Type Input Strict Input Source Conditions
bool bool ✓ Python & JSON
bytes bytes ✓ Python
callable Any ✓ Python callable() check must return True.
complex complex ✓ Python
date date ✓ Python
datetime datetime ✓ Python
deque deque ✓ Python
dict dict ✓ Python
float float ✓ Python & JSON bool is explicitly forbidden.
float int ✓ Python & JSON
float Any ✓ Python Must implement __float__() or __index__().
float Decimal ✓ Python
float Fraction ✓ Python
frozendict frozendict ✓ Python frozendict is only available in Python 3.15 and above.
frozenset frozenset ✓ Python
int int ✓ Python & JSON bool is explicitly forbidden.
list list ✓ Python
namedtuple dict ✓ Python
namedtuple list ✓ Python
namedtuple namedtuple ✓ Python
namedtuple tuple ✓ Python
namedtuple Iterable ✓ Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
namedtuple Mapping ✓ Python Must implement the mapping interface and have an items() method.
namedtuple NamedTuple ✓ Python
set set ✓ Python
str str ✓ Python & JSON
time time ✓ Python
timedelta timedelta ✓ Python
tuple tuple ✓ Python
type type ✓ Python
Any Any ✓ Python & JSON
ByteSize int ✓ Python & JSON
ByteSize str ✓ Python & JSON
Counter Counter ✓ Python
Decimal Decimal ✓ Python
Enum Enum ✓ Python
Fraction Fraction ✓ Python
Hashable Any ✓ Python & JSON isinstance() check against Hashable must return True.
IPv4Address IPv4Address ✓ Python
IPv4Address IPv4Interface ✓ Python
IPv4Interface IPv4Interface ✓ Python
IPv4Network IPv4Network ✓ Python
IPv6Address IPv6Address ✓ Python
IPv6Address IPv6Interface ✓ Python
IPv6Interface IPv6Interface ✓ Python
IPv6Network IPv6Network ✓ Python
InstanceOf Any ✓ Python isinstance() check must return True.
IntEnum IntEnum ✓ Python
Iterable Any ✓ Python Any object for which iter() succeeds. Items are validated lazily.
Literal Any ✓ Python & JSON Input must be equal to one of the literal values.
NamedTuple dict ✓ Python
NamedTuple list ✓ Python
NamedTuple namedtuple ✓ Python
NamedTuple tuple ✓ Python
NamedTuple Iterable ✓ Python Any iterable except str, bytes, bytearray, dict and mappings, e.g. generators.
NamedTuple Mapping ✓ Python Must implement the mapping interface and have an items() method.
NamedTuple NamedTuple ✓ Python
None None ✓ Python & JSON
OrderedDict OrderedDict ✓ Python
Path Path ✓ Python
Pattern bytes ✓ Python Input must be a valid pattern. Not valid for Pattern[str].
Pattern str ✓ Python & JSON Input must be a valid pattern. Not valid for Pattern[bytes].
Pattern Pattern ✓ Python The pattern type (str or bytes) must match.
Sequence list ✓ Python
Sequence tuple ✓ Python
TypedDict dict ✓ Python
UUID UUID ✓ Python