Mutually Exclusive Fields¶
Mutually Exclusive Fields
is a Schema Constraint.
It ensures that, out of a set of fields, only one field is defined at any time.
Usage Example¶
schema:
name: One
package: test.exclusive_fields
root: one
fields:
- name: name
type: string
is_required: true
- name: alpha
type: string
- name: beta
type: string
- name: gamma
type: string
constraints:
- name: Mutually exclusive fields
arguments:
fields:
- alpha
- beta
- gamma
In the above example, only one of the fields (alpha
, beta
, and gamma
) can be defined.
one:
name: GoodOne
alpha: alpha
Here, alpha
is the only one defined. This would pass the Mutaully Exclusive Fields
constraint.
one:
name: bad
alpha: alpha
beta: beta
Here, both alpha
and beta
are defined, which would fail the Mutaully Exclusive Fields
constraint.