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