The Workflow YAML specification below has a starting state with a single UI input.
It prompts the user to enter an individual's age.
Once this information has been submitted:
The Workflow transitions into a transform state
Validation is performed
The event returned depends on the age entered
There is one transition and it leads to a success state from the transform state.
xxxxxxxxxx
---
name: "Exercise 1 {add your name here}"
definition_version: 1.0.0
schema_version: 3.1.0
starting_state: get_age
end_states:
- state: success
result: SUCCESSFUL
# ----------------------YOUR CODE GOES HERE----------------------
# ---------------------------------------------------------------
states:
get_age:
display_name: Ask user to enter an age
state_ui:
ui_actions:
- action_id: specify_age
event: age_specified
display_name: Submit
ui_inputs:
- key: age
display_name: Enter an age to test
number_input:
min_value: 1
max_value: 150
transitions:
- to: check_age
trigger: age_specified
check_age:
display_name: Check age entered by the user
expected_context_keys:
- age
type: transform
transform_ref: check_age
transitions:
- to: success
trigger: is_valid_age
# ----------------------YOUR CODE GOES HERE----------------------
# ---------------------------------------------------------------
success: {}
# ----------------------YOUR CODE GOES HERE----------------------
# ---------------------------------------------------------------
transforms:
check_age: |
if int(context['age']) < 18:
return ['is_underage', {}]
else:
return ['is_valid_age', {}