Files
David Flanagan dcfb3202bd cue.validator: fix deprecated --strict flag
The --strict flag was deprecated in CUE 0.14.0 and causes NixOS builds
to fail with: '--strict is deprecated; use "jsonschema+strict:" as
shown in "cue help filetypes"'

Since strict validation is now the default behavior in CUE, we can
safely remove this flag without changing functionality.
2025-08-07 19:20:03 +01:00

24 lines
761 B
Nix

{
cue,
writeShellScript,
lib,
}:
# `document` must be a fragment of definition or structure that the input data will be matched against.
# `document` must exist in the Cue schema file provided (`cueSchemaFile`).
# The result is a script that can be used to validate the input data (JSON/YAML and more can be supported depending on Cue)
# against the fragment described by `document` or the whole definition.
# The script will be strict and enforce concrete values, i.e. partial documents are not supported.
cueSchemaFile:
{
document ? null,
}:
writeShellScript "validate-using-cue" ''
${cue}/bin/cue \
--all-errors \
vet \
--concrete \
"$1" \
${cueSchemaFile} \
${lib.optionalString (document != null) "-d \"${document}\""}
''