Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(functions): expand xor function and add exclusive option for or functionality #2616

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
12 changes: 7 additions & 5 deletions docs/reference/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,25 @@ unused-definition:

## xor

Communicate that one of these properties is required, and no more than one is allowed to be defined.
Communicate that one of these properties is required, and exactly one or more than one is allowed to be defined, depending on `exclusive` option. FunctionOptions must contain any non-zero number of properties, `exclusive: true` (the default) requires that _exactly_ one of them is defined, `exclusive: false` requires that _at least_ one but possibly more than one is defined. (For only one property specified, `exclusive` is not relevant and this is the same as the `defined` function for the single property.)

<!-- title: functionOptions -->

| name | description | type | required? |
| ---------- | ----------------------- | ---------- | --------- |
| properties | the properties to check | `string[]` | yes |
| name | description | type | required? |
| ---------- | ------------------------------------------------------------------------------------------- | ---------- | --------- |
| properties | the properties to check | `string[]` | yes |
| exclusive | `true` by default for `xor`; when not truthy multiple matches are allowed for `or` behavior | `boolean` | no |

<!-- title: example -->

```yaml
components-examples-value-or-externalValue:
description: Examples should have either a `value` or `externalValue` field.
description: Examples should have either a `value` or `externalValue` field, but not both; unless `exclusive` is false
given: "$.components.examples.*"
then:
function: xor
functionOptions:
exclusive: false
properties:
- externalValue
- value
Expand Down
Loading