PLAIN PYTHON · ZERO RUNTIME DEPS
Errors and privacy
Catch released text and structured validation errors without assuming input redaction.
Choose structured errors explicitly
The default text mode raises ValueError. error_mode='structured' raises ValidationError, a ValueError subclass with an issues list. Each issue carries a string path, message, expected, and got. These are the released fields; canonical token paths and details are not available here.
from zodify import ValidationError, validate
try:
validate({"port": int}, {"port": "wrong"}, error_mode="structured")
except ValidationError as error:
assert error.issues[0]["path"] == "port"
assert error.issues[0]["expected"] == "int"
else:
raise AssertionError("Expected structured failure")
print("errors: passed")
Expected output: errors: passed
Treat error text as potentially sensitive
Coercion failures can include the original string, and custom callback exceptions can include callback messages. An issues list is not a promise of redaction. Avoid logging entire errors for credentials or user secrets; prefer an application-controlled message and a reviewed field identifier.
Legacy paths use dots and brackets. Literal field names containing punctuation can be ambiguous. Do not parse these strings into an authoritative structural path.