@@ -11,6 +11,9 @@ validate: [string]: {
11
11
validate: t1: schema: {b: string}
12
12
validate: t2: schema: {a: <3}
13
13
14
+ validate: disjunctionRequired: schema: {a!: int} | {b!: int}
15
+ validate: disjunctionClosed: schema: close({a: int}) | close({b: int})
16
+
14
17
// Issue #2395
15
18
validate: enforceRequired: {
16
19
str: "{}"
@@ -93,9 +96,9 @@ validate.t2.result: error in call to encoding/json.Validate: invalid value 10 (o
93
96
./in.cue:9:27
94
97
json.Validate:1:6
95
98
unmarshal.trailingInvalid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON:
96
- ./in.cue:39 :11
99
+ ./in.cue:42 :11
97
100
unmarshal.trailingValid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON:
98
- ./in.cue:39 :11
101
+ ./in.cue:42 :11
99
102
100
103
Result:
101
104
import "encoding/json"
@@ -115,6 +118,24 @@ validate: {
115
118
}
116
119
result: _|_ // validate.t2.result: error in call to encoding/json.Validate: validate.t2.schema.a: invalid value 10 (out of bound <3)
117
120
}
121
+ disjunctionRequired: {
122
+ str: *"{\"a\":10}" | string
123
+ schema: {
124
+ a!: int
125
+ } | {
126
+ b!: int
127
+ }
128
+ result: json.Validate(str, schema)
129
+ }
130
+ disjunctionClosed: {
131
+ str: *"{\"a\":10}" | string
132
+ schema: {
133
+ a: int
134
+ } | {
135
+ b: int
136
+ }
137
+ result: json.Validate(str, schema)
138
+ }
118
139
119
140
// Issue #2395
120
141
enforceRequired: {
@@ -251,7 +272,7 @@ unmarshalStream: {
251
272
diff old new
252
273
--- old
253
274
+++ new
254
- @@ -75 ,23 +75 ,15 @@
275
+ @@ -93 ,23 +93 ,15 @@
255
276
}
256
277
marshalStream: {
257
278
t1: {
@@ -284,7 +305,7 @@ diff old new
284
305
[{
285
306
a: 1
286
307
}, {
287
- @@ -99 ,11 +91 ,7 @@
308
+ @@ -117 ,11 +109 ,7 @@
288
309
}]
289
310
}
290
311
t3: {
@@ -297,7 +318,7 @@ diff old new
297
318
[{
298
319
a: "\\ \" & < >"
299
320
}, {
300
- @@ -113 ,31 +101 ,27 @@
321
+ @@ -131 ,31 +119 ,27 @@
301
322
}
302
323
marshal: {
303
324
t1: {
@@ -356,9 +377,9 @@ validate.t2.result: error in call to encoding/json.Validate: invalid value 10 (o
356
377
./in.cue:9:27
357
378
json.Validate:1:6
358
379
unmarshal.trailingInvalid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON:
359
- ./in.cue:39 :11
380
+ ./in.cue:42 :11
360
381
unmarshal.trailingValid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON:
361
- ./in.cue:39 :11
382
+ ./in.cue:42 :11
362
383
363
384
Result:
364
385
import "encoding/json"
@@ -378,6 +399,24 @@ validate: {
378
399
}
379
400
result: _|_ // validate.t2.result: error in call to encoding/json.Validate: validate.t2.schema.a: invalid value 10 (out of bound <3)
380
401
}
402
+ disjunctionRequired: {
403
+ str: *"{\"a\":10}" | string
404
+ schema: {
405
+ a!: int
406
+ } | {
407
+ b!: int
408
+ }
409
+ result: json.Validate(str, schema)
410
+ }
411
+ disjunctionClosed: {
412
+ str: *"{\"a\":10}" | string
413
+ schema: {
414
+ a: int
415
+ } | {
416
+ b: int
417
+ }
418
+ result: json.Validate(str, schema)
419
+ }
381
420
382
421
// Issue #2395
383
422
enforceRequired: {
0 commit comments