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¶
context.remove_definitions(bad_data)
context.remove_definitions(test_schema)
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:
In the above example, if alpha
is set to true, beta
must be empty.
- name: empty_field_name
value: beta
This set of data would pass the If True Then Empty
constraint, because beta
is not defined.
beta:
- one
- two
"""
BAD_DATA_1 = """
This set of data would fail the If True Then Empty
constraint, because beta
is defined.