'JsonSchema definition for either or value
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.
Solution 1:[1]
You'll want to use an anyOf wrapped around the checks for either property. Exact matches can be done with const.
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ether |
