Errors

Issue codes

Every IssueCode variant with its key, parameters and the checks that produce it.

IssueCode::key() returns the stable key in the second column. The "Template keys" are what translations look up, most specific first.

Types and sizes

Variantkey()ParamsProduced by
InvalidType { expected, received }invalid_typeexpected, receivedwrong JSON type; a present null for a required value
TooSmall { origin, minimum, inclusive }too_smallorigin, minimum, inclusivemin, gte, gt, positive, non_negative, min_len, min_size, min_keys, …
TooBig { origin, maximum, inclusive }too_bigorigin, maximum, inclusivemax, lte, lt, negative, max_len, max_size, …
InvalidLength { origin, expected }invalid_lengthorigin, expectedlen(n), tuples
NotIntnot_int—integer schemas given a fraction
NotFinitenot_finite—deprecated finite()
NotMultipleOf { divisor }not_multiple_ofdivisormultiple_of
NotSafeIntegernot_safe_integer—safe()

minimum / maximum are serde_json::Value: a number, or a string for decimal, date, datetime and time origins. inclusive: false means an exclusive bound (gt, lt, positive).

SizeOrigin

origin says what was measured. SizeOrigin::key() values: string, number, decimal, array, tuple, set, record, object, bytes, date, datetime, time, duration, file, image_width, image_height, port, contains.

Formats

Variantkey()ParamsProduced by
InvalidString { validation }invalid_stringvalidation (+ prefix / suffix / substring)string formats, regex, starts_with, ends_with, contains
InvalidFormat { format }invalid_formatformatnon-string schemas that parse text: decimal, ip_network, ipv4_network, ipv6_network, socket_addr, base64, base64url, hex, image, from_str
InvalidDate { kind }invalid_datekind (date / datetime / time)malformed date strings
InvalidTimezoneOffset { expected }invalid_timezone_offsetexpected (±HH:MM)timezone_offset_only
NotInPast { kind } / NotInFuture { kind }not_in_past / not_in_futurekindpast() / future()

StringValidation keys: email, url, url_strict, uri, uuid, uuid_v1, uuid_v4, uuid_v7, ip, ipv4, ipv6, cidr, mac, hostname, slug, color, currency, country_code, locale, cron, regex, starts_with, ends_with, contains, hex, credit_card, phone, phone_e164, semver, semver_full, jwt, ascii, alpha, alphanumeric, lowercase, uppercase, base64, base64url, json, iso_date, iso_datetime, iso_time, cuid2, ulid, nanoid, emoji.

Values and composites

Variantkey()ParamsProduced by
InvalidLiteral { expected }invalid_literalexpectedliteral
InvalidEnumValue { options }invalid_enum_valueoptionsenumeration, enum_of
InvalidUnioninvalid_union—every union variant failed (followed by each variant's issues)
InvalidDiscriminator { options }invalid_discriminatoroptionsunknown discriminator value
NotUniquenot_unique—array().unique()
MissingContainsmissing_contains—array().contains(..)
DuplicateKeyduplicate_key—map with a repeated key
InvalidMapEntryinvalid_map_entry—map entry that is not [key, value]
MissingFieldmissing_field—absent required key
UnrecognizedFieldunrecognized_field—unknown key in a strict() object
JsonTooDeep { max_depth }json_too_deepmax_depthjson_value().max_depth(n)

Paths and files

Variantkey()Params
PathOutsideBase { base }path_outside_basebase
PathNotAbsolute / PathNotRelativepath_not_absolute / path_not_relative—
PathNotFound / PathNotFile / PathNotDirpath_not_found / path_not_file / path_not_dir—
FileTypeNotAllowed { kind, actual, allowed }file_type_not_allowedkind, actual, allowed
FileTypeDenied { kind, actual }file_type_deniedkind, actual
FileTypeUnknown { kind }file_type_unknownkind
ChecksumMismatch { algorithm }checksum_mismatchalgorithm (SHA-256 / MD5)
MissingExifmissing_exif—
IoErrorio_error—

FileTypeKind keys: extension, media_type, magic_type.

Other

Variantkey()ParamsProduced by
SerializeError { detail }serialize_errordetailvalidate() when a value cannot be serialized
ParseErrorparse_error—input that is not valid JSON; from_serde failures
Custom { code }the user codecoderefine, custom, super_refine, your own IssueBuilder issues

Template keys

Codes with a sub-kind look up a specific template first:

CodeKeys tried
too_smalltoo_small.<origin>, too_small (exclusive bounds: too_small_exclusive.<origin>, too_small_exclusive)
too_bigtoo_big.<origin>, too_big (exclusive: too_big_exclusive…)
invalid_lengthinvalid_length.<origin>, invalid_length
invalid_stringinvalid_string.<validation>, invalid_string
invalid_formatinvalid_format.<format>, invalid_format
invalid_date, not_in_past, not_in_future<key>.<kind>, <key>
Custom { code }<code>, custom
everything else<key>

IssueCode::message_keys() returns this list for an issue. Size templates also have plural variants (too_small.string_one), see i18n.