in src/stepfunctions/steps/choice_rule.py [0:0]
def __init__(self, variable, operator, value):
"""
Args:
variable (str): Path to the variable to compare.
operator (str): Comparison operator to be applied.
value (type depends on *operator*): Constant value or Path to compare `variable` against.
Raises:
ValueError: If `variable` doesn't start with '$'
ValueError: If `value` is not the appropriate datatype for the `operator` specified.
"""
# Validate the variable name
if not isinstance(variable, StepInput) and not variable.startswith('$'):
raise ValueError("Expected variable must be a placeholder or must start with '$', but got '{variable}'".format(variable=variable))
# Validate the variable value
# If operator ends with Path, value must be a Path
if operator.endswith("Path"):
if not isinstance(value, StepInput) and not value.startswith('$'):
raise ValueError("Expected value must be a placeholder or must start with '$', but got '{value}'".format(value=value))
else:
for k, v in VALIDATORS.items():
if operator.startswith(k) and not isinstance(value, v):
raise ValueError('Expected value to be a {type}, but got {value}'.format(type=k, value=value))
self.variable = variable
self.operator = operator
self.value = value