Skip to content

Commit 2fb6f45

Browse files
committed
internal/core/validate: fix validation of disjunctions for evalv3
The v3 evaluator represents disjunctions slightly differently from v2. The validator did not take this into account and did not dereference disjunctions when needed. Fixes #3422 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Idb47d65d9ba44ebb7d133feee33dc71dddb13314 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200732 Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 2d329b5 commit 2fb6f45

File tree

13 files changed

+66
-184
lines changed

13 files changed

+66
-184
lines changed

encoding/jsonschema/external_teststats.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ v2:
66

77
v3:
88
schema extract (pass / total): 1003 / 1637 = 61.3%
9-
tests (pass / total): 3214 / 7175 = 44.8%
10-
tests on extracted schemas (pass / total): 3214 / 3678 = 87.4%
9+
tests (pass / total): 3259 / 7175 = 45.4%
10+
tests on extracted schemas (pass / total): 3259 / 3678 = 88.6%

encoding/jsonschema/testdata/external/tests/draft2019-09/allOf.json

+5-20
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,14 @@
4040
"data": {
4141
"foo": "baz"
4242
},
43-
"valid": false,
44-
"skip": {
45-
"v3": "unexpected success"
46-
}
43+
"valid": false
4744
},
4845
{
4946
"description": "mismatch first",
5047
"data": {
5148
"bar": 2
5249
},
53-
"valid": false,
54-
"skip": {
55-
"v3": "unexpected success"
56-
}
50+
"valid": false
5751
},
5852
{
5953
"description": "wrong type",
@@ -124,31 +118,22 @@
124118
"bar": 2,
125119
"baz": null
126120
},
127-
"valid": false,
128-
"skip": {
129-
"v3": "unexpected success"
130-
}
121+
"valid": false
131122
},
132123
{
133124
"description": "mismatch second allOf",
134125
"data": {
135126
"foo": "quux",
136127
"bar": 2
137128
},
138-
"valid": false,
139-
"skip": {
140-
"v3": "unexpected success"
141-
}
129+
"valid": false
142130
},
143131
{
144132
"description": "mismatch both",
145133
"data": {
146134
"bar": 2
147135
},
148-
"valid": false,
149-
"skip": {
150-
"v3": "unexpected success"
151-
}
136+
"valid": false
152137
}
153138
]
154139
},

encoding/jsonschema/testdata/external/tests/draft2019-09/oneOf.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,14 @@
184184
"data": {
185185
"bar": 2
186186
},
187-
"valid": true,
188-
"skip": {
189-
"v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
190-
}
187+
"valid": true
191188
},
192189
{
193190
"description": "second oneOf valid (complex)",
194191
"data": {
195192
"foo": "baz"
196193
},
197-
"valid": true,
198-
"skip": {
199-
"v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
200-
}
194+
"valid": true
201195
},
202196
{
203197
"description": "both oneOf valid (complex)",
@@ -330,20 +324,14 @@
330324
"data": {
331325
"bar": 8
332326
},
333-
"valid": true,
334-
"skip": {
335-
"v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
336-
}
327+
"valid": true
337328
},
338329
{
339330
"description": "second oneOf valid",
340331
"data": {
341332
"foo": "foo"
342333
},
343-
"valid": true,
344-
"skip": {
345-
"v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
346-
}
334+
"valid": true
347335
},
348336
{
349337
"description": "both oneOf valid",

encoding/jsonschema/testdata/external/tests/draft2020-12/allOf.json

+5-20
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,14 @@
4040
"data": {
4141
"foo": "baz"
4242
},
43-
"valid": false,
44-
"skip": {
45-
"v3": "unexpected success"
46-
}
43+
"valid": false
4744
},
4845
{
4946
"description": "mismatch first",
5047
"data": {
5148
"bar": 2
5249
},
53-
"valid": false,
54-
"skip": {
55-
"v3": "unexpected success"
56-
}
50+
"valid": false
5751
},
5852
{
5953
"description": "wrong type",
@@ -124,31 +118,22 @@
124118
"bar": 2,
125119
"baz": null
126120
},
127-
"valid": false,
128-
"skip": {
129-
"v3": "unexpected success"
130-
}
121+
"valid": false
131122
},
132123
{
133124
"description": "mismatch second allOf",
134125
"data": {
135126
"foo": "quux",
136127
"bar": 2
137128
},
138-
"valid": false,
139-
"skip": {
140-
"v3": "unexpected success"
141-
}
129+
"valid": false
142130
},
143131
{
144132
"description": "mismatch both",
145133
"data": {
146134
"bar": 2
147135
},
148-
"valid": false,
149-
"skip": {
150-
"v3": "unexpected success"
151-
}
136+
"valid": false
152137
}
153138
]
154139
},

encoding/jsonschema/testdata/external/tests/draft2020-12/oneOf.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,14 @@
184184
"data": {
185185
"bar": 2
186186
},
187-
"valid": true,
188-
"skip": {
189-
"v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
190-
}
187+
"valid": true
191188
},
192189
{
193190
"description": "second oneOf valid (complex)",
194191
"data": {
195192
"foo": "baz"
196193
},
197-
"valid": true,
198-
"skip": {
199-
"v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
200-
}
194+
"valid": true
201195
},
202196
{
203197
"description": "both oneOf valid (complex)",
@@ -330,20 +324,14 @@
330324
"data": {
331325
"bar": 8
332326
},
333-
"valid": true,
334-
"skip": {
335-
"v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
336-
}
327+
"valid": true
337328
},
338329
{
339330
"description": "second oneOf valid",
340331
"data": {
341332
"foo": "foo"
342333
},
343-
"valid": true,
344-
"skip": {
345-
"v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:1:1\n generated.cue:2:8\n instance.json:1:1\n"
346-
}
334+
"valid": true
347335
},
348336
{
349337
"description": "both oneOf valid",

encoding/jsonschema/testdata/external/tests/draft4/allOf.json

+5-20
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,14 @@
3939
"data": {
4040
"foo": "baz"
4141
},
42-
"valid": false,
43-
"skip": {
44-
"v3": "unexpected success"
45-
}
42+
"valid": false
4643
},
4744
{
4845
"description": "mismatch first",
4946
"data": {
5047
"bar": 2
5148
},
52-
"valid": false,
53-
"skip": {
54-
"v3": "unexpected success"
55-
}
49+
"valid": false
5650
},
5751
{
5852
"description": "wrong type",
@@ -122,31 +116,22 @@
122116
"bar": 2,
123117
"baz": null
124118
},
125-
"valid": false,
126-
"skip": {
127-
"v3": "unexpected success"
128-
}
119+
"valid": false
129120
},
130121
{
131122
"description": "mismatch second allOf",
132123
"data": {
133124
"foo": "quux",
134125
"bar": 2
135126
},
136-
"valid": false,
137-
"skip": {
138-
"v3": "unexpected success"
139-
}
127+
"valid": false
140128
},
141129
{
142130
"description": "mismatch both",
143131
"data": {
144132
"bar": 2
145133
},
146-
"valid": false,
147-
"skip": {
148-
"v3": "unexpected success"
149-
}
134+
"valid": false
150135
}
151136
]
152137
},

encoding/jsonschema/testdata/external/tests/draft4/oneOf.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,14 @@
9797
"data": {
9898
"bar": 2
9999
},
100-
"valid": true,
101-
"skip": {
102-
"v3": "invalid value {bar:2} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n"
103-
}
100+
"valid": true
104101
},
105102
{
106103
"description": "second oneOf valid (complex)",
107104
"data": {
108105
"foo": "baz"
109106
},
110-
"valid": true,
111-
"skip": {
112-
"v3": "invalid value {foo:\"baz\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:int},null | bool | number | string | [] | {foo!:string}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n"
113-
}
107+
"valid": true
114108
},
115109
{
116110
"description": "both oneOf valid (complex)",
@@ -240,20 +234,14 @@
240234
"data": {
241235
"bar": 8
242236
},
243-
"valid": true,
244-
"skip": {
245-
"v3": "invalid value {bar:8} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n"
246-
}
237+
"valid": true
247238
},
248239
{
249240
"description": "second oneOf valid",
250241
"data": {
251242
"foo": "foo"
252243
},
253-
"valid": true,
254-
"skip": {
255-
"v3": "invalid value {foo:\"foo\"} (does not satisfy matchN(1, [null | bool | number | string | [] | {bar!:_,baz?:_},null | bool | number | string | [] | {foo!:_}])): 2 matched, expected 1:\n generated.cue:2:1\n generated.cue:2:8\n instance.json:1:1\n"
256-
}
244+
"valid": true
257245
},
258246
{
259247
"description": "both oneOf valid",

encoding/jsonschema/testdata/external/tests/draft6/allOf.json

+5-20
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,14 @@
3939
"data": {
4040
"foo": "baz"
4141
},
42-
"valid": false,
43-
"skip": {
44-
"v3": "unexpected success"
45-
}
42+
"valid": false
4643
},
4744
{
4845
"description": "mismatch first",
4946
"data": {
5047
"bar": 2
5148
},
52-
"valid": false,
53-
"skip": {
54-
"v3": "unexpected success"
55-
}
49+
"valid": false
5650
},
5751
{
5852
"description": "wrong type",
@@ -122,31 +116,22 @@
122116
"bar": 2,
123117
"baz": null
124118
},
125-
"valid": false,
126-
"skip": {
127-
"v3": "unexpected success"
128-
}
119+
"valid": false
129120
},
130121
{
131122
"description": "mismatch second allOf",
132123
"data": {
133124
"foo": "quux",
134125
"bar": 2
135126
},
136-
"valid": false,
137-
"skip": {
138-
"v3": "unexpected success"
139-
}
127+
"valid": false
140128
},
141129
{
142130
"description": "mismatch both",
143131
"data": {
144132
"bar": 2
145133
},
146-
"valid": false,
147-
"skip": {
148-
"v3": "unexpected success"
149-
}
134+
"valid": false
150135
}
151136
]
152137
},

0 commit comments

Comments
 (0)