Skip to content

Translation keys

Every error a built-in validator raises carries a translation_key naming the exact sentence of its default message, and placeholders, the raw values that sentence interpolates. Together they let a consumer render errors in its own words or language without parsing strings; see Custom error messages for the pattern.

The keys are public API: renaming or removing one is a breaking change, the same as renaming a function. Where two validators produce the same sentence, they share the key, so one translation covers both. A custom msg= on a validator replaces the rendered text but keeps the key.

Templates are str.format style. The canonical source is the catalog in probatio._messages; this table mirrors it. One entry is a fragment rather than a sentence: did_you_mean is appended to a suggestion-carrying error’s message, with the close matches also available raw on context["candidates"] (see how suggestions compose).

KeyEnglish template
allowed_at_most_one_ofat most one of {keys} is allowed
allowed_one_ofexactly one of {keys} is allowed
byte_length_out_of_boundsbyte length out of bounds
cannot_be_changed{field!r} cannot be changed
cannot_convert_to_setcannot be converted to a set: {detail}
contains_duplicate_itemscontains duplicate items: {items}
contains_unhashable_elementscontains unhashable elements: {detail}
did_you_mean, did you mean {candidates}?
does_not_match_patterndoes not match the expected pattern
element_not_validitem {position} ({item}) does not match any validator
exclusive_grouptwo or more values in the same group of exclusion {group!r}
expected_alphaexpected only ASCII letters
expected_alphanumericexpected only ASCII letters and digits
expected_asciiexpected only ASCII characters
expected_base64_stringexpected a Base64 string
expected_booleanexpected a boolean
expected_cidrexpected a CIDR network
expected_collectionexpected a collection: {detail}
expected_credit_card_numberexpected a credit card number
expected_data_uriexpected a data URI
expected_discriminatorexpected {key} to be one of {values}
expected_durationexpected a duration
expected_duration_detailedexpected a duration like H:MM, H:MM:SS, an ISO 8601 duration like PT1H30M, or a number of seconds
expected_email_addressexpected an email address
expected_fqdnexpected a fully-qualified domain name
expected_hex_colorexpected a hex color like #rrggbb
expected_hex_stringexpected a hex string
expected_hexadecimal_integerexpected a hexadecimal integer
expected_hostnameexpected a hostname
expected_iana_time_zoneexpected an IANA time zone
expected_ibanexpected an IBAN
expected_ipexpected an IP address
expected_ipv4expected an IPv4 address
expected_ipv6expected an IPv6 address
expected_iso_dateexpected an ISO 8601 date
expected_iso_datetimeexpected an ISO 8601 datetime
expected_iso_timeexpected an ISO 8601 time
expected_json_stringexpected a JSON string
expected_mac_addressexpected a MAC address
expected_mappingexpected a mapping
expected_no_whitespaceexpected no whitespace
expected_objectexpected a {cls!r}
expected_percentageexpected a percentage between 0 and 100
expected_phone_numberexpected a phone number
expected_portexpected a port number between 1 and 65535
expected_printable_asciiexpected only printable ASCII characters
expected_sequenceexpected a {expected}
expected_sequence_of_itemsexpected a sequence of {count} items
expected_slugexpected a slug
expected_stringexpected a string
expected_timezone_aware_datetimeexpected a timezone-aware datetime
expected_typeexpected {expected}
expected_type_or_one_ofexpected {expected} or one of {values}
expected_ulidexpected a ULID
expected_unix_timestampexpected a Unix timestamp
expected_urlexpected a URL
expected_url_with_fqdnexpected a URL with a fully-qualified domain name
expected_utc_offsetexpected a UTC offset like +01:00, Z, or UTC
expected_uuidexpected a UUID
expected_uuid_versionexpected a version {version} UUID
expected_valid_regexexpected a valid regular expression
inclusive_groupsome but not all values in the same group of inclusion {group!r}
invalid_credit_card_numberinvalid credit card number
invalid_data_uriinvalid data URI
invalid_ibaninvalid IBAN
invalid_jsoninvalid JSON
invalid_phone_numberinvalid phone number
invalid_valueinvalid value
invalid_value_or_typeinvalid value or type
key_not_allowedkey not allowed
length_maxlength of value must be at most {max}
length_minlength of value must be at least {min}
max_containsexpected at most {max} matching item(s)
min_containsexpected at least {min} matching item(s)
must_not_match_not_schemavalue must not match the 'not' schema
no_valid_valueno valid value found
not_a_block_devicenot a block device
not_a_collectionvalue is not a collection
not_a_directorynot a directory
not_a_fifonot a FIFO
not_a_filenot a file
not_a_pathnot a path
not_a_socketnot a socket
not_a_symlinknot a symlink
not_a_valid_optionnot a valid option
not_a_valid_valuenot a valid value
not_a_valid_value_detailnot a valid value: {detail}
path_does_not_existpath does not exist
precision_must_equalprecision must be equal to {precision}
range_maxvalue must be at most {max}
range_max_exclusivevalue must be lower than {max}
range_minvalue must be at least {min}
range_min_exclusivevalue must be higher than {min}
recursion_too_deepdata is nested too deeply for this recursive schema
requiredrequired key not provided
required_any_ofat least one of {keys} is required
required_none_or_all_ofeither none or all of {keys} are required
required_one_ofexactly one of {keys} is required
required_when_absent{key!r} is required when {triggers} is absent
required_when_present{key!r} is required when {triggers} is present
required_when_value{key!r} is required when {conditions}
scale_must_equalscale must be equal to {scale}
too_many_validvalue matched {passed} alternatives, expected at most {max}
value_does_not_match_formatvalue does not match expected format {format}
value_has_no_precisionvalue has no precision
value_multiple_ofvalue must be a multiple of {factor}
value_must_be_number_stringvalue must be a number enclosed in a string
value_must_containvalue must contain {item!r}
value_must_end_withvalue must end with {suffix!r}
value_must_start_withvalue must start with {prefix!r}
value_no_lengthvalue has no length
value_not_allowedvalue is not allowed
value_not_emptyvalue must not be empty
value_not_equalvalue is not equal to {target!r}
value_not_one_ofvalue must not be one of {values}
value_not_sortedvalue is not sorted
value_one_ofvalue must be one of {values}
value_was_not_falsevalue was not false
value_was_not_truevalue was not true
write_once_already_set{field!r} is write-once and already set

Three keys are JSON Schema-only: max_contains, min_contains, and must_not_match_not_schema. They fire only from schemas built by from_json_schema (see the JSON Schema guide); no hand-written validator emits them.