nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 23 lines 761 B view raw
1{ 2 cue, 3 writeShellScript, 4 lib, 5}: 6# `document` must be a fragment of definition or structure that the input data will be matched against. 7# `document` must exist in the Cue schema file provided (`cueSchemaFile`). 8# The result is a script that can be used to validate the input data (JSON/YAML and more can be supported depending on Cue) 9# against the fragment described by `document` or the whole definition. 10# The script will be strict and enforce concrete values, i.e. partial documents are not supported. 11cueSchemaFile: 12{ 13 document ? null, 14}: 15writeShellScript "validate-using-cue" '' 16 ${cue}/bin/cue \ 17 --all-errors \ 18 vet \ 19 --concrete \ 20 "$1" \ 21 ${cueSchemaFile} \ 22 ${lib.optionalString (document != null) "-d \"${document}\""} 23''