Eight Ways JSON Schema Validation Passes Bad Data
An order payload with a bogus email, an impossible timestamp, five extra fields and a missing required value went through jsonschema with zero errors. Nothing was misconfigured in one obvious place; eight defaults simply stayed quiet at once. I actually ran twenty-plus samples through jsonschema 4.26.0 on CPython 3.13.14, then checked every "pass" against the specification text and copied four real error strings verbatim.
TL;DR:
formatis annotation-only by default, and the spec forces implementations to keep assertion off; this box registered only 8 format checkers,date-timewas not one of them, and2026-13-45T99:99:99Zpassed.properties,requiredanditemsonly apply when the instance is already that type, so a missing top-leveltype: objectlets arrays and strings through untouched.multipleOf: 0.01is a division test: 5 of 9 sample values were rejected, including 19.99.- Draft changes are worse:
dependenciesneither errors nor works under 2020-12, so the same schema gives two answers on two clients.
format is an annotation, not an assertion
The official type reference says it plainly: "By default, format is just an annotation and does not affect validation." The validation spec goes further in §7.2.1: "The implementation MUST provide options to enable and disable such evaluation and MUST be disabled by default." Turning it off is mandatory; turning it on is optional.
Five strings all returned true on the default path: not-an-email, a@b, x y@example.com, @@, and the empty string. With a format_checker attached, not-an-email and the empty string were rejected, but a@b and @@ still passed. The project's own FAQ explains why: the email format "only provides a sanity check, not full RFC 5322 validation."
The quieter problem is that the checker set is incomplete. With only the base package installed, FORMAT_CHECKER.checkers held 8 keys: date, email, idn-email, idn-hostname, ipv4, ipv6, regex, uuid. date-time, hostname, uri, duration and json-pointer were absent because each needs an extra package (rfc3339-validator, fqdn, rfc3987, isoduration, jsonpointer). The docs spell out the consequence: "If a dependency is not installed when using a checker that requires it, validation will succeed without throwing an error."
| format | registered here | bad sample | result |
|---|---|---|---|
| date | yes | 2026-02-30 | rejected |
| ipv4 | yes | 999.1.1.1 | rejected |
| uuid | yes | not-uuid | rejected |
| date-time | no | 2026-13-45T99:99:99Z | passed |
| hostname | no | @@ bad host @@ | passed |
| uri | no | not a uri | passed |
Same schema, same validator; the difference is which checkers actually got installed. Either install jsonschema[format], or stop treating format as type checking, or write your own with FormatChecker.checks.
properties is not a type assertion
The docs note that "By default, leaving out properties is valid," which most people know. Fewer notice that the keyword does not even care whether the instance is an object.
Three measurements:
{"properties": {"a": {"type": "integer"}}}passed for[1, 2], passed for"hello", and only failed for{"a": "x"}.{"required": ["a"]}passed for[1, 2]and for"hi".{"items": {"type": "integer"}}passed for{"a": "x"}.
The mechanism is simple: keywords dispatch on instance type, and a non-matching type means the whole block is skipped. Skipped is not failed. Drop the top-level "type": "object" and every field rule you wrote only applies to an instance that happens to be a dict.
The contrast makes it obvious: a dict with 8 wrong fields produced 8 errors; the same data sent in as a list produced 0. The most valuable line in a schema is not required, it is the type on line one.
additionalProperties is open by default, and only sees its own level
The docs say "By default any additional properties are allowed." I fed a schema that declares only id a payload with 5 extra keys: 0 errors. Adding "additionalProperties": false produced 1 error listing every offending key at once: "Additional properties are not allowed ('extra_a', 'extra_b', 'extra_c', 'extra_d', 'extra_e' were unexpected)." One error, not five, so never estimate the number of stray fields from the error count.
The second trap appears when you compose schemas. The docs warn: "additionalProperties only recognizes properties declared in the same subschema as itself." I put shared fields in $defs, pulled them in with allOf and $ref, and closed the outer object with additionalProperties: false. The intent was to catch stray keys; the result rejected id itself: "Additional properties are not allowed ('id' was unexpected)."
The fix is unevaluatedProperties (draft 2019-09 onward), described as "similar to additionalProperties except that it can recognize properties declared in subschemas." The same structure with unevaluatedProperties: false accepted id and rejected nope, as intended.
The validator never touches your data
The FAQ asks this exact question, and the first line answers it: "The basic answer is that the specification does not require that default actually do anything." A sharper sentence follows: letting default modify an instance can produce "an instance modified by the default would pass validation the first time, but fail the second."
Measured: with "retries": {"type": "integer", "default": 3} and an input of {}, validate() returned normally, the dict stayed {}, and "retries" in data was False. Defaults need either your own setdefault or the validators.extend recipe from the FAQ.
The second half is existence. {"type": "object", "properties": {"amount": {"type": "number"}}} validates {} happily, and the next line, data["amount"], raises KeyError('amount'). required checks key presence only: {"required": ["token"]} accepts {"token": null}.
So every field rule has to be written twice, once in properties for the type and once in required for existence. Skip the second and the validator hands you a green light while production hands you a 500.
Number semantics: 1.0 is an integer, true is not
The validation spec §6.1.1 defines it as "integer which matches any number with a zero fractional part" — the test is the value, not the literal spelling. The official type page adds a footnote: "JSON does not have separate types for integer and floating-point."
For {"type": "integer"}: 1 passed, 1.0 passed, 0.0 passed, 1e3 passed; 1.5, "1", true, false and Decimal("1") were all rejected. For {"type": "number"}, true and false still failed while Decimal("1") passed.
Equality is where intuition breaks:
{"enum": [1]}rejects true and accepts 1.0.{"const": 1}accepts 1.0.{"uniqueItems": true}treats[1, 1.0]as duplicates (fails) and[1, true]as distinct (passes).
JSON equality is not Python equality, and the direction is inverted from what Python programmers expect: 1 == True is true in Python but two different values to the validator, while 1 == 1.0 is the same value in both. Someone who remembers it backwards gets boolean flags and money deduplication wrong at the same time.
Practical consequence: boolean fields need "type": "boolean", never 0/1 as a flag; money should never be a float.
oneOf with two matches is a failure
Three-way type fields are the usual victim. oneOf demands exactly one branch to match, so two matches fail the whole thing.
With one branch requiring a and another requiring b, the instance {"a": 1, "b": 2} satisfied both: oneOf failed, and the message read "{'a': 1, 'b': 2} is valid under each of {'type': 'object', 'required': ['b']}, {'type': 'object', 'required': ['a']}". The same branches under anyOf passed.
Two details in that message mislead: the branches print in reverse declaration order, and the whole instance is repr'd into the string, which can leak sensitive fields into logs. When you see it, check whether both branches are too loose; do not start changing data types.
multipleOf is a division test
The spec says: "A numeric instance is valid only if division by this keyword's value results in an integer." The test is the division result, not the number of decimal places.
For {"multipleOf": 0.01}, 5 of 9 samples failed (55.6%): 0.02, 0.03, 0.1 and 100.0 passed; 0.07, 19.99, 0.1+0.2, 2.675 and 1.13 failed. The arithmetic is checkable by hand: 0.07/0.01 = 7.000000000000001 and 19.99/0.01 = 1998.9999999999998 are not integers.
Two workable fixes:
- Store money in minor units as integers (1999 for 19.99) and use
{"type": "integer", "multipleOf": 1}. - Keep Decimal instances and make multipleOf a Decimal too:
Decimal("19.99")againstDecimal("0.01")passed.
What makes this one dangerous is that it looks correct. Teams add a 0.01 multiple and believe two-decimal money is locked down, while a slice of ordinary prices gets rejected — often the 19.99 or 0.29 kind.
Switching drafts turns old keywords into annotations
The core spec says "Unknown keywords SHOULD be treated as annotations," meaning an implementation that does not know a keyword simply ignores it. During a version migration that becomes local silence and lost rules in production.
Appendix A records that dependencies was split into dependentRequired (array form) and dependentSchemas (schema form). For one schema, {"dependencies": {"card": ["cvv"]}}:
- With
$schemaset to draft-07,{"card": "4111"}failed with "'cvv' is a dependency of 'card'". - With
$schemaset to 2020-12, the same instance passed with no warning at all. - With no
$schema,validate()assumed 2020-12 and passed.
The array form of items shows the same divergence from the other side: check_schema accepted it under draft-07 and raised SchemaError: [{'type': 'string'}, {'type': 'integer'}] is not of type 'object', 'boolean' under 2020-12. One schema, one valid input, one invalid input, decided entirely by dialect.
So $schema is not decoration: pin it, and confirm that server and client pick the same draft. Cross-language calls deserve an extra check on which draft the other implementation supports.
Troubleshooting: four real errors and what they leave out
Error one: SchemaError: 'strng' is not valid under any of the given schemas
A misspelled type. The message says the value is invalid without naming the keyword or the legal values. Call Validator.check_schema(schema) first, and pull legal type names from META_SCHEMA instead of typing them from memory.
Error two: _WrappedReferencingError: PointerToNowhere: '/$defs/nope' does not exist within {'$ref': '#/$defs/nope'}
A $ref pointing at a key that does not exist. Note that within prints the entire schema, not the $defs section, which is easy to misread. Check the $defs key names and the #/ path spelling, especially the leading #.
Error three: ValidationError: 'a' is a required property
Clear enough, but it carries no location: path on a root object is an empty list. For nested data use absolute_path or json_path; one nested sample yielded $.items[1].sku. Log the path, not str(error).
Error four (a false alarm): Additional properties are not allowed ('id' was unexpected)
id is declared in the $ref'd base schema yet reported as extra. That is the allOf composition problem from earlier, not a data problem. Switch to unevaluatedProperties; do not "fix" the payload.
FAQ
Q: Can I skip type: object and rely on required?
No. required only applies to object instances; arrays and strings skip the block entirely, which is the same as no validation.
Q: Will format: date-time ever raise an error?
Not with only the base package installed. date-time needs rfc3339-validator, and the docs state that a missing dependency means "validation will succeed without throwing an error."
Q: Is multipleOf: 0.01 fine for money?
No, it rejects 19.99. Use integer minor units, or Decimal instances with a Decimal multipleOf.
Q: Does installing jsonschema[format] make format reliable?
Not fully. email is still a sanity check, and @@ still passes. Write your own checker with FormatChecker.checks when the exact syntax matters.
What to change on Monday
Of the eight passes, only two are catchable in code review: a missing type and a missing required. The other six live in defaults and draft versions, invisible in the diff and visible only when you run samples. A passing validator means "nothing you wrote was violated," not "this data is safe to store."
Three rules are worth pinning in the project: fix $schema and keep it identical everywhere; install the format extras explicitly or drop format; store money in minor units.
Adjacent problems on the same line: the rounding piece covers round, Decimal and float, and pairs directly with the multipleOf finding here; the config parsing piece covers how YAML 1.1 and 1.2 type the same literal differently; the argv piece covers where arguments get lost before they reach a Namespace. All three share one theme: by the time the value reaches your code, it is no longer the value you wrote.
No affiliate links and no Amazon recommendations in this article. Every number above comes from local runs and quoted specification text.
👉 Join Xiaomi MiMo Platform: Leading AI model platform with cost-effective inference
👉 Join Aliyun AI: Top AI products with exclusive coupons for business innovation
📌 This article was AI-assisted generated and human-reviewed | TechPassive — An AI-driven content testing site focused on real tool reviews
🔗 Recommended Tools
These are carefully selected tools. Using our affiliate links supports us to keep producing quality content:
As an Amazon Associate, I earn from qualifying purchases at no extra cost to you.