gts 0.12.0

Global Type System (GTS) library for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
#![allow(clippy::unwrap_used, clippy::expect_used)]
use super::*;
use serde_json::json;
/// Asserts that some error names both the offending location and the keyword
/// the test is about.
///
/// Admission fails closed and turns every diagnostic - including
/// `NotProvable` - into an error string, so a bare "the vector is not empty"
/// passes on any undecidable result and proves nothing about the rule under
/// test.
#[track_caller]
fn assert_reports(errors: &[String], path: &str, keyword: &str) {
    assert!(
        errors
            .iter()
            .any(|error| error.contains(path) && error.contains(keyword)),
        "expected an error naming '{path}' and '{keyword}': {errors:?}"
    );
}

// -- effective schema --------------------------------------------------

/// Closedness must survive `allOf` composition: a permissive overlay may
/// not reopen a branch that closed `additionalProperties`, or a derivation
/// could smuggle properties past a closed base.
#[test]
fn test_flatten_keeps_closed_additional_properties_through_allof() {
    let schema = json!({
        "type": "object",
        "additionalProperties": true,
        "allOf": [
            {"additionalProperties": false},
            {"additionalProperties": true}
        ]
    });

    assert_eq!(
        flatten_schema(&schema).get("additionalProperties"),
        Some(&Value::Bool(false))
    );
}

/// The same, spelled through schemas that are only boolean-*equivalent*.
#[test]
fn test_flatten_keeps_boolean_equivalent_closed_additional_properties() {
    let schema = json!({
        "type": "object",
        "allOf": [
            {"additionalProperties": {"not": {}}},
            {"additionalProperties": {}}
        ]
    });

    let flattened = flatten_schema(&schema);
    assert_eq!(
        flattened
            .get("additionalProperties")
            .and_then(boolean_schema_value),
        Some(false),
        "{flattened}"
    );
}

// -- validate_derivation_compatibility ------------------------------------

#[test]
fn test_partially_open_base_accepts_compatible_derived_property() {
    let base = json!({
        "type": "object",
        "additionalProperties": {"type": "string"}
    });
    let derived = json!({
        "type": "object",
        "additionalProperties": {"type": "string"},
        "properties": {
            "foo": {"type": "string", "maxLength": 5}
        }
    });

    let errors = validate_derivation_compatibility(&base, &derived, "base", "derived");
    assert!(
        errors.is_empty(),
        "compatible refinement must be accepted: {errors:?}"
    );
}

#[test]
fn test_partially_open_base_rejects_incompatible_derived_property() {
    let base = json!({
        "type": "object",
        "additionalProperties": {"type": "string"}
    });
    let derived = json!({
        "type": "object",
        "additionalProperties": {"type": "string"},
        "properties": {
            "foo": {"type": "integer"}
        }
    });

    let errors = validate_derivation_compatibility(&base, &derived, "base", "derived");
    assert!(
        errors
            .iter()
            .any(|error| error.contains("foo") && error.contains("changes type")),
        "incompatible refinement must be rejected: {errors:?}"
    );
}

#[test]
fn test_boolean_equivalent_additional_properties_control_derivation() {
    let open_base = json!({
        "type": "object",
        "additionalProperties": {}
    });
    let closed_base = json!({
        "type": "object",
        "additionalProperties": {"not": {}}
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "foo": {"type": "integer"}
        }
    });

    assert!(validate_derivation_compatibility(&open_base, &derived, "base", "derived").is_empty());
    let errors = validate_derivation_compatibility(&closed_base, &derived, "base", "derived");
    assert!(
        errors
            .iter()
            .any(|error| error.contains("foo") && error.contains("closed")),
        "false-equivalent additionalProperties must close the model: {errors:?}"
    );
}

#[test]
fn test_compatible_tightening() {
    let base = json!({
        "type": "object",
        "properties": {
            "v": {"type": "string", "maxLength": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "v": {"type": "string", "maxLength": 50}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert!(errs.is_empty(), "tightening should be ok: {errs:?}");
}

/// GTS pins no draft (spec sec 11), so a derivation may declare a newer dialect
/// than the base it tightens - the dialect difference alone is not an admission
/// failure.
#[test]
fn test_newer_dialect_alone_is_admitted() {
    let base = json!({
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {"v": {"type": "string", "maxLength": 100}}
    });
    let derived = json!({
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {"v": {"type": "string", "maxLength": 50}}
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert!(
        errs.is_empty(),
        "a newer dialect is not a failure: {errs:?}"
    );
}

/// The exemption is scoped to the dialect diagnostic: a real violation
/// alongside a dialect change is still reported.
#[test]
fn test_newer_dialect_does_not_excuse_loosening() {
    let base = json!({
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {"v": {"type": "string", "maxLength": 100}}
    });
    let derived = json!({
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {"v": {"type": "string", "maxLength": 200}}
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert_reports(&errs, "$.v", "maxLength");
    assert!(
        !errs.iter().any(|e| e.contains("dialect")),
        "the dialect change itself must stay exempt: {errs:?}"
    );
}

#[test]
fn test_incompatible_loosening_max_length() {
    let base = json!({
        "type": "object",
        "properties": {
            "v": {"type": "string", "maxLength": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "v": {"type": "string", "maxLength": 200}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert_reports(&errs, "$.v", "maxLength");
}

#[test]
fn test_incompatible_loosening_maximum() {
    let base = json!({
        "type": "object",
        "properties": {
            "n": {"type": "integer", "maximum": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "n": {"type": "integer", "maximum": 200}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.n", "maximum");
}

#[test]
fn test_incompatible_loosening_minimum() {
    let base = json!({
        "type": "object",
        "properties": {
            "n": {"type": "integer", "minimum": 10}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "n": {"type": "integer", "minimum": 5}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.n", "minimum");
}

#[test]
fn test_enum_expansion_fails() {
    let base = json!({
        "type": "object",
        "properties": {
            "s": {"type": "string", "enum": ["a", "b"]}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "s": {"type": "string", "enum": ["a", "b", "c"]}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.s", "enum");
}

#[test]
fn test_enum_subset_ok() {
    let base = json!({
        "type": "object",
        "properties": {
            "s": {"type": "string", "enum": ["a", "b", "c"]}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "s": {"type": "string", "enum": ["a"]}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(errs.is_empty(), "{errs:?}");
}

#[test]
fn test_additional_properties_false_blocks_new_prop() {
    let base = json!({
        "type": "object",
        "properties": {"a": {"type": "string"}},
        "additionalProperties": false
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "a": {"type": "string"},
            "b": {"type": "string"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "'b'", "closed");
}

#[test]
fn test_value_compatibility_catches_closed_descendant_branch_orphan() {
    let base = json!({
        "type": "object",
        "properties": {
            "routing": {
                "type": "object",
                "properties": {
                    "source": {"type": "string"}
                }
            }
        }
    });
    let derived = json!({
        "type": "object",
        "allOf": [
            base,
            {
                "type": "object",
                "properties": {
                    "routing": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "target": {"type": "string"}
                        }
                    }
                }
            }
        ]
    });

    let errs = validate_derivation_compatibility(&base, &derived, "base", "derived");
    assert!(
        errs.iter()
            .any(|e| e.contains("routing.source") && e.contains("additionalProperties")),
        "closed descendant branch should not orphan an ancestor property: {errs:?}"
    );
}

#[test]
fn test_closed_descendant_branch_fails_when_depth_guard_is_hit() {
    fn nested_object(depth: usize) -> Value {
        let mut schema = json!({"type": "object", "properties": {}});
        for _ in 0..depth {
            schema = json!({
                "type": "object",
                "properties": {
                    "child": schema
                }
            });
        }
        schema
    }

    let base = nested_object(MAX_RECURSION_DEPTH);
    let derived = nested_object(MAX_RECURSION_DEPTH);

    let errs = validate_closed_descendant_branches(&base, &derived, "base", "derived");
    assert!(
        errs.iter()
            .any(|err| err.contains("exceeded maximum nesting depth")),
        "depth guard should fail closed instead of silently accepting: {errs:?}"
    );
}

#[test]
fn test_additional_properties_inherited_via_allof_not_loosening() {
    // Derived omits `additionalProperties` at its own root but its
    // properties set is identical to base's (typical shape produced
    // by the macro emitter after the allOf+$ref refactor — the
    // derived overlay nests its new fields under base's generic
    // slot, leaving the top-level property set unchanged).
    //
    // Per JSON Schema allOf composition, the base's
    // `additionalProperties: false` is inherited via $ref, so this
    // shape is **not** loosening and OP#12 must not flag it.
    let base = json!({
        "type": "object",
        "properties": {"a": {"type": "string"}},
        "additionalProperties": false
    });
    let derived = json!({
        "type": "object",
        "properties": {"a": {"type": "string"}}
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.is_empty(),
        "Derived inheriting closedness via $ref should not be flagged: {errs:?}"
    );
}

#[test]
fn test_additional_properties_explicit_true_still_loosens() {
    // A direct derived schema that has no inherited closed branch and
    // explicitly says `additionalProperties: true` loosens a closed base.
    let base = json!({
        "type": "object",
        "properties": {"a": {"type": "string"}},
        "additionalProperties": false
    });
    let derived = json!({
        "type": "object",
        "properties": {"a": {"type": "string"}},
        "additionalProperties": true
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.iter()
            .any(|e| e.contains("loosens additionalProperties")),
        "Explicit additionalProperties: true must still flag as loosening: {errs:?}"
    );
}

#[test]
fn test_open_base_allows_new_prop() {
    let base = json!({
        "type": "object",
        "properties": {"a": {"type": "string"}}
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "a": {"type": "string"},
            "b": {"type": "string"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(errs.is_empty(), "{errs:?}");
}

/// The base declares no `required`, so switching the property off is the only
/// thing the derivation changes and the only thing that may be reported.
#[test]
fn test_property_disabled_fails() {
    let base = json!({
        "type": "object",
        "properties": {"x": {"type": "string"}}
    });
    let derived = json!({
        "type": "object",
        "properties": {"x": false}
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.iter()
            .any(|e| e.contains("disables property defined in") && e.contains("'x'")),
        "{errs:?}"
    );
}

#[test]
fn test_nested_object_loosening_caught() {
    let base = json!({
        "type": "object",
        "properties": {
            "inner": {
                "type": "object",
                "properties": {
                    "v": {"type": "integer", "maximum": 10}
                }
            }
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "inner": {
                "type": "object",
                "properties": {
                    "v": {"type": "integer", "maximum": 20}
                }
            }
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.inner.v", "maximum");
}

#[test]
fn test_boolean_true_schema_loosens_constrained_property() {
    // Derived replaces a constrained property with boolean `true` schema
    // (which accepts anything), silently loosening the contract.
    let base = json!({
        "type": "object",
        "properties": {
            "age": {"type": "integer", "maximum": 120}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "age": true
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.age", "boolean schema");
}

#[test]
fn test_boolean_true_schema_loosens_typed_property() {
    // A boolean `true` derived property removes the base type constraint.
    let base = json!({
        "type": "object",
        "properties": {
            "name": {"type": "string"}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "name": true
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.name", "boolean schema");
}

#[test]
fn test_enum_tightening_allows_omitting_bounds() {
    // Derived introduces enum, which is strictly tighter than maxLength.
    // Omitting maxLength when adding enum is NOT loosening.
    let base = json!({
        "type": "object",
        "properties": {
            "tier": {"type": "string", "maxLength": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "tier": {"type": "string", "enum": ["gold", "platinum"]}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.is_empty(),
        "enum tightening should allow omitting maxLength: {errs:?}"
    );
}

#[test]
fn test_const_tightening_allows_omitting_bounds_and_pattern() {
    // Derived introduces const, which is the tightest possible constraint.
    // Omitting bounds and pattern when adding const is NOT loosening.
    let base = json!({
        "type": "object",
        "properties": {
            "v": {"type": "string", "maxLength": 100, "pattern": "^[a-z]+$"}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "v": {"type": "string", "const": "hello"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.is_empty(),
        "const tightening should allow omitting maxLength and pattern: {errs:?}"
    );
}

#[test]
fn test_enum_tightening_allows_omitting_numeric_bounds() {
    // Derived introduces enum for an integer property, omitting min/max.
    let base = json!({
        "type": "object",
        "properties": {
            "priority": {"type": "integer", "minimum": 0, "maximum": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "priority": {"type": "integer", "enum": [1, 5, 10]}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.is_empty(),
        "enum tightening should allow omitting min/max: {errs:?}"
    );
}

#[test]
fn test_omitting_bounds_without_enum_or_const_still_fails() {
    // Derived omits maxLength without adding enum or const — still loosening.
    let base = json!({
        "type": "object",
        "properties": {
            "code": {"type": "string", "maxLength": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "code": {"type": "string"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert_reports(&errs, "$.code", "maxLength");
}

#[test]
fn test_derived_const_must_be_in_base_enum() {
    // Base has enum, derived narrows to const — but const value must be in base enum.
    let base = json!({
        "type": "object",
        "properties": {
            "status": {"type": "string", "enum": ["active", "inactive"]}
        }
    });
    let derived_ok = json!({
        "type": "object",
        "properties": {
            "status": {"type": "string", "const": "active"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived_ok, "b", "d");
    assert!(errs.is_empty(), "const in base enum should be ok: {errs:?}");

    let derived_bad = json!({
        "type": "object",
        "properties": {
            "status": {"type": "string", "const": "deleted"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived_bad, "b", "d");
    assert_reports(&errs, "$.status", "enum");
}

#[test]
fn test_const_violates_minimum() {
    // Base has minimum 42, derived sets const 32 — must fail.
    let base = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "minimum": 42}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "const": 32}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert_reports(&errs, "$.score", "minimum");
}

#[test]
fn test_const_satisfies_minimum() {
    // Base has minimum 42, derived sets const 50 — should pass.
    let base = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "minimum": 42}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "const": 50}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert!(
        errs.is_empty(),
        "const 50 >= minimum 42 should pass: {errs:?}"
    );
}

#[test]
fn test_enum_value_violates_maximum() {
    // Base has maximum 100, derived enum includes 200 — must fail.
    let base = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "maximum": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "enum": [10, 50, 200]}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert_reports(&errs, "$.score", "maximum");
}

#[test]
fn test_enum_values_within_bounds() {
    // Base has minimum 10 and maximum 100, all enum values within range — should pass.
    let base = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "minimum": 10, "maximum": 100}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "score": {"type": "integer", "enum": [10, 50, 100]}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert!(
        errs.is_empty(),
        "all enum values in range should pass: {errs:?}"
    );
}

#[test]
fn test_const_string_violates_max_length() {
    // Base has maxLength 5, derived const is "toolong" (7 chars) — must fail.
    let base = json!({
        "type": "object",
        "properties": {
            "code": {"type": "string", "maxLength": 5}
        }
    });
    let derived = json!({
        "type": "object",
        "properties": {
            "code": {"type": "string", "const": "toolong"}
        }
    });
    let errs = validate_derivation_compatibility(&base, &derived, "base~", "derived~");
    assert_reports(&errs, "$.code", "maxLength");
}

/// Admission must fail closed on a document nested past the shared bound.
///
/// `declared_schema` returns such a schema unreduced and `flatten_schema`
/// stops merging its deepest branches, so the disabled-property rule alone
/// could miss a violation down there. It never gets the chance: the bounded
/// walks report the nesting first and every diagnostic becomes an error, so a
/// derivation this deep is refused rather than admitted unchecked.
#[test]
fn test_derivation_nested_beyond_the_bound_is_refused() {
    let nested_all_of = |leaf: Value| {
        let mut schema = leaf;
        for _ in 0..70 {
            schema = json!({"allOf": [schema]});
        }
        schema
    };
    let base = nested_all_of(json!({"type": "object", "properties": {"x": {"type": "string"}}}));
    // Disables a base property - the violation the shallow case reports by name.
    let derived = nested_all_of(json!({"type": "object", "properties": {"x": false}}));

    let errs = validate_derivation_compatibility(&base, &derived, "b", "d");
    assert!(
        errs.iter().any(|error| error.contains("nesting depth")),
        "the bound must be reported, not silently applied: {errs:?}"
    );

    // The same violation without the nesting is still named precisely, so the
    // test above is about the bound and not about a broken rule.
    let errs = validate_derivation_compatibility(
        &json!({"type": "object", "properties": {"x": {"type": "string"}}}),
        &json!({"type": "object", "properties": {"x": false}}),
        "b",
        "d",
    );
    assert!(
        errs.iter()
            .any(|error| error.contains("disables property defined in") && error.contains("'x'")),
        "{errs:?}"
    );
}