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.
7 cueSchemaFile: { document ? null }:
8 writeShellScript "validate-using-cue" ''
16 ${lib.optionalString (document != null) "-d \"${document}\""}