I am writing a JSON schema for helm chart values.yaml wherein the yaml file is as follows:
accessID: "" // user set this value when installing individual chart
global:
accessID: "" // user set this when installing the parent which this chart is part of
How can I write JSON schema (version 7) to validate either one of this should have a non empty string.
You'll want to use an
anyOf
wrapped around the checks for either property. Exact matches can be done withconst
.https://json-schema.org/understanding-json-schema/reference/conditionals.html https://json-schema.org/understanding-json-schema/reference/generic.html#constant-values https://json-schema.org/understanding-json-schema/reference/object.html