Issue codes
IssueCode::key() returns the stable key in the second column. The "Template keys" are what translations look up, most specific first.
Types and sizes
| Variant | key() | Params | Produced by |
|---|---|---|---|
InvalidType { expected, received } | invalid_type | expected, received | wrong JSON type; a present null for a required value |
TooSmall { origin, minimum, inclusive } | too_small | origin, minimum, inclusive | min, gte, gt, positive, non_negative, min_len, min_size, min_keys, … |
TooBig { origin, maximum, inclusive } | too_big | origin, maximum, inclusive | max, lte, lt, negative, max_len, max_size, … |
InvalidLength { origin, expected } | invalid_length | origin, expected | len(n), tuples |
NotInt | not_int | — | integer schemas given a fraction |
NotFinite | not_finite | — | deprecated finite() |
NotMultipleOf { divisor } | not_multiple_of | divisor | multiple_of |
NotSafeInteger | not_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
| Variant | key() | Params | Produced by |
|---|---|---|---|
InvalidString { validation } | invalid_string | validation (+ prefix / suffix / substring) | string formats, regex, starts_with, ends_with, contains |
InvalidFormat { format } | invalid_format | format | non-string schemas that parse text: decimal, ip_network, ipv4_network, ipv6_network, socket_addr, base64, base64url, hex, image, from_str |
InvalidDate { kind } | invalid_date | kind (date / datetime / time) | malformed date strings |
InvalidTimezoneOffset { expected } | invalid_timezone_offset | expected (±HH:MM) | timezone_offset_only |
NotInPast { kind } / NotInFuture { kind } | not_in_past / not_in_future | kind | past() / 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
| Variant | key() | Params | Produced by |
|---|---|---|---|
InvalidLiteral { expected } | invalid_literal | expected | literal |
InvalidEnumValue { options } | invalid_enum_value | options | enumeration, enum_of |
InvalidUnion | invalid_union | — | every union variant failed (followed by each variant's issues) |
InvalidDiscriminator { options } | invalid_discriminator | options | unknown discriminator value |
NotUnique | not_unique | — | array().unique() |
MissingContains | missing_contains | — | array().contains(..) |
DuplicateKey | duplicate_key | — | map with a repeated key |
InvalidMapEntry | invalid_map_entry | — | map entry that is not [key, value] |
MissingField | missing_field | — | absent required key |
UnrecognizedField | unrecognized_field | — | unknown key in a strict() object |
JsonTooDeep { max_depth } | json_too_deep | max_depth | json_value().max_depth(n) |
Paths and files
| Variant | key() | Params |
|---|---|---|
PathOutsideBase { base } | path_outside_base | base |
PathNotAbsolute / PathNotRelative | path_not_absolute / path_not_relative | — |
PathNotFound / PathNotFile / PathNotDir | path_not_found / path_not_file / path_not_dir | — |
FileTypeNotAllowed { kind, actual, allowed } | file_type_not_allowed | kind, actual, allowed |
FileTypeDenied { kind, actual } | file_type_denied | kind, actual |
FileTypeUnknown { kind } | file_type_unknown | kind |
ChecksumMismatch { algorithm } | checksum_mismatch | algorithm (SHA-256 / MD5) |
MissingExif | missing_exif | — |
IoError | io_error | — |
FileTypeKind keys: extension, media_type, magic_type.
Other
| Variant | key() | Params | Produced by |
|---|---|---|---|
SerializeError { detail } | serialize_error | detail | validate() when a value cannot be serialized |
ParseError | parse_error | — | input that is not valid JSON; from_serde failures |
Custom { code } | the user code | code | refine, custom, super_refine, your own IssueBuilder issues |
Template keys
Codes with a sub-kind look up a specific template first:
| Code | Keys tried |
|---|---|
too_small | too_small.<origin>, too_small (exclusive bounds: too_small_exclusive.<origin>, too_small_exclusive) |
too_big | too_big.<origin>, too_big (exclusive: too_big_exclusive…) |
invalid_length | invalid_length.<origin>, invalid_length |
invalid_string | invalid_string.<validation>, invalid_string |
invalid_format | invalid_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.