You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***{} must compile to the Empty form and accept any JSON value** (RFC 8927 §2.2)
524
+
***Do not introduce compatibility modes that reinterpret {} with object semantics**
525
+
***Specs from json-typedef-spec are authoritative for behavior and tests**
526
+
***If a test, doc, or code disagrees with RFC 8927 about {}, the test/doc/code is wrong**
527
+
***We log at INFO when {} is compiled to help users who come from non-JTD validators**
528
528
529
-
When implementing JTD validation logic, ensure strict RFC 8927 compliance rather than maintaining compatibility with other JSON schema specifications.
529
+
Per RFC 8927 §3.3.1: "If a schema is of the 'empty' form, then it accepts all instances. A schema of the 'empty' form will never produce any error indicators."
Per **RFC 8927 (JSON Typedef)**, the empty schema `{}` is the **empty form** and
301
+
**accepts all JSON instances** (null, boolean, numbers, strings, arrays, objects).
303
302
304
-
⚠️ Note: Some JSON Schema / AJV implementations treat `{}` as "accept anything".
305
-
This library is RFC 8927–strict and will reject documents with any properties.
306
-
A log message at INFO level is emitted when `{}` is compiled to highlight this difference.
303
+
> RFC 8927 §2.2 "Forms":
304
+
> `schema = empty / ref / type / enum / elements / properties / values / discriminator / definitions`
305
+
> `empty = {}`
306
+
> **Empty form:** A schema in the empty form accepts all JSON values and produces no errors.
307
+
308
+
⚠️ Note: Some tools or in-house validators mistakenly interpret `{}` as "object with no
309
+
properties allowed." **That is not JTD.** This implementation follows RFC 8927 strictly.
310
+
311
+
### Logging
312
+
When a `{}` schema is compiled, the validator logs at **INFO** level:
313
+
> `Empty schema {} encountered. Per RFC 8927 this means 'accept anything'. Some non-JTD validators interpret {} with object semantics; this implementation follows RFC 8927.`
**Important Note**: Some JSON Schema and AJV implementations treat `{}` as "accept anything". This JTD validator is RFC 8927-strict and will reject documents with additional properties. An INFO-level log message is emitted when `{}` is compiled to highlight this semantic difference.
293
+
-**Form**: `empty = {}`
294
+
-**Behavior**: **accepts all instances**; produces no validation errors.
295
+
-**RFC 8927 §3.3.1**: "If a schema is of the 'empty' form, then it accepts all instances. A schema of the 'empty' form will never produce any error indicators."
296
+
-**Common pitfall**: confusing JTD with non-JTD validators that treat `{}` as an empty-object schema.
297
+
-**Implementation**: compile `{}` to `EmptySchema` and validate everything as OK.
0 commit comments