nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 writeCueValidator,
3 runCommand,
4 writeText,
5 ...
6}:
7
8let
9 validator = writeCueValidator (writeText "schema.cue" ''
10 #Def1: {
11 field1: string
12 }
13 '') { document = "#Def1"; };
14in
15runCommand "cue-validation" { } ''
16 cat > valid.json <<EOF
17 { "field1": "abc" }
18 EOF
19 cat > invalid.json <<EOF
20 { "field2": "abc" }
21 EOF
22 ${validator} valid.json
23 if ${validator} invalid.json; then
24 echo "this example should fail"
25 exit 1
26 fi
27 touch $out
28''