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

In the below example, only one of the fields (alpha, beta, and gamma) can be defined.

TEST_EXCLUSIVE_FIELDS = """
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

Here, alpha is the only one defined. This would pass the Mutaully Exclusive Fields constraint.

GOOD_DATA_1 = """
one:
    name: GoodOne

Here, both alpha and beta are defined, which would fail the Mutaully Exclusive Fields constraint.

BAD_DATA_1 = """
one:
    name: BadOne
    alpha: alpha