-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema validation is sometimes too strict resulting in the reporting of spurious errors. Disable schema checking for now. Note that any errors in the schema will anyway surface when unified with the data instance. Fixes #1479 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I2336f8453ee448c80c482e4eb19e0a99fd84d1a0 Signed-off-by: Marcel van Lohuizen <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/531263 Reviewed-by: Marcel van Lohuizen <[email protected]>
- Loading branch information
Showing
6 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#Issue 1479 | ||
|
||
exec cue eval x.cue data.json y.cue | ||
|
||
|
||
# Demonstrate checks are ok | ||
exec cue eval x.cue data.json | ||
cmp stdout stdout.golden | ||
|
||
# Import JSON and verify that we can assert checks are ok | ||
exec cue import data.json | ||
exec cue eval x.cue data.cue y.cue | ||
|
||
# Assert checks ok using CUE + JSON | ||
exec cue eval x.cue data.json y.cue | ||
|
||
-- data.json -- | ||
{ | ||
"team": { | ||
"alice": [ | ||
"EM" | ||
], | ||
"bob": [ | ||
"TL" | ||
] | ||
} | ||
} | ||
-- x.cue -- | ||
import ( | ||
"list" | ||
) | ||
|
||
#Team: [string]: [...("EM" | "IC" | "TL")] | ||
|
||
team: #Team | ||
|
||
checks: { | ||
enoughMembers: { | ||
ok: len(team) >= 1 | ||
} | ||
|
||
hasManager: { | ||
ok: len([ for m in team if list.Contains(m, "EM") {m}]) >= 1 | ||
} | ||
} | ||
-- y.cue -- | ||
checks: [string]: ok: true | ||
|
||
-- stdout.golden -- | ||
#Team: {} | ||
team: { | ||
alice: ["EM"] | ||
bob: ["TL"] | ||
} | ||
checks: { | ||
enoughMembers: { | ||
ok: true | ||
} | ||
hasManager: { | ||
ok: true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters