If True Then Empty¶
If True Then Empty
is a Schema Constraint that checks to ensure the empty_field_name
is empty if bool_field_name
is true.
Usage Example¶
In the below example, if alpha
is set to true, beta
must be empty.
TEST_SCHEMA = """
schema:
name: IfTrueEmptyTest
package: test.if_true_then_empty
root: one
fields:
- name: name
type: string
- name: alpha
type: bool
- name: beta
type: string[]
constraints:
- name: If true then empty
arguments:
- name: bool_field_name
value: alpha
- name: empty_field_name
The following set of data would pass the If True Then Empty
constraint, because beta
is not defined.
GOOD_DATA_1 = """
one:
name: GoodData1
The following set of data would pass the If True Then Empty
constraint, because alpha
is set to false
allowing beta
to be defined.
GOOD_DATA_2 = """
one:
name: GoodData2
alpha: false
beta:
- one
The following set of data would fail the If True Then Empty
constraint, because alpha
is set to true
and beta
is defined.
BAD_DATA_1 = """
one:
name: BadData1
alpha: true
beta:
- one