This handler evaluates whether a value is valid based on a pattern or a list of patterns.
Type: value_evaluation_handler
Here's an explanation of the available attributes:
/s
. If it matches, the input is valid.The handler emits the following events:
VALID
: If the provided input matches the pattern.ALREADY_VALID
: If the provided input matches a pattern that has already been successfully validated.ALL_VALID
: If all elements of the to_evaluate
collection have been validated successfully.INVALID
: If the provided input does not match any pattern.The payload structure is as follows:
{ "command": "VALID", "device": { "modality": "value-evaluation", "name": "value-evaluation", "source": "value-evaluation", "descriptor": "value-evaluation" }, "payload": { "code": "i am legend" } } { "command": "INVALID", "device": { "modality": "value-evaluation", "name": "value-evaluation", "source": "value-evaluation", "descriptor": "value-evaluation" }, "payload": { } }
<context> <param name="validations" type="string"></param> </context> <handlers> <value_evaluation_handler> <code_word_extraction>validate</code_word_extraction> <list name="to_evaluate" listType="UNNAMED"> <elem>machine .+</elem> <elem>station .+</elem> </list> </value_evaluation_handler> </handlers> <states> <onevent> <rule id="is_valid"> <expression> <![CDATA[ #{event(value-evaluation):command} == 'VALID' ]]> </expression> <actions> <setvar id="add_validation"> <context_of>step</context_of> <context_update> <param name="validations" type="string">#{validations} #{event:payload.code}</param> </context_update> </setvar> </actions> </rule> <rule id="all_valid"> <expression> <![CDATA[ #{event(value-evaluation):command} == 'ALL_VALID' ]]> </expression> <actions> <finish_workflow id="exit"/> </actions> </rule> <rule id="invalid_input"> <expression> <![CDATA[ #{event(value-evaluation):command} == 'INVALID' ]]> </expression> <actions> <ui_notification id="invalid_value" type="ERROR" duration="SHORT" show_immediately="true"> <message>"Not a valid value!</message> </ui_notification> </actions> </rule> </onevent> </states>
This handler is used to implement barcode scanning via dedicated scanning hardware. It extracts scanner or speech input based on a list of patterns and checks if at least one of these patterns is valid.
Type: value_extractor_handler
Here's an explanation of the available attribute:
The different elements are as follows:
or
, because each group has to contain an allowed value or scan.
true
will save store the variables in scopte of the workflow instead.
resume
.
The handler emits the following events:
VALID_EXTRACTION
or INVALID_EXTRACTION
: The handler will check any input event with the BARCODE
and SPEECH
modalities (if the code_word_extraction
parameter is provided) and emit an event with the VALID_EXTRACTION
or INVALID_EXTRACTION
commands.INVALID_PATTERN
: If the provided pattern contains a syntax error, the handler will emit an event with the INVALID_PATTERN
command .The payload structure is as follows:
{ "command": "VALID_EXTRACTION", "device": { "modality": "value_extractor", "name": "value_extractor", "source": "value_extractor", "descriptor": "value_extractor" }, "payload": { "technology": "SCAN", // [SCAN, VOICE] "code": "123456789", "speech_command": "null" } } { "command": "INVALID_PATTERN", "device": { "modality": "value_extractor", "name": "value_extractor", "source": "value_extractor", "descriptor": "value_extractor" }, "payload": { "technology": "pattern", "code": "(.()*", "speech_command": "null" } }
<value_extractor_handler pattern="(.+)_(.+)" code_word_extraction="USER"> <grp> <param name="grp_1" type="string">prefix</param> <param name="grp_2" type="string">suffix</param> </grp> </value_extractor_handler>
A code such as "test_user" will be successfully extracted. Afterwards, #{prefix}
will contain "test" and #{suffix}
will contain "user".
<context> <list name="user_name_list" listType="UNNAMED"> <elem>barry</elem> <elem>white</elem> </list> </context> <handlers> <value_extractor_handler pattern="(.+)_(.+)"> <code_word_extraction></code_word_extraction> <input>admin_barry</input> <extract_to_workflow>true</extract_to_workflow> <grp> <param name="grp_1" type="string">user_role</param> <param name="grp_2" type="string">user_name</param> </grp> <allowed_values> <list name="grp_1" listType="UNNAMED"> <elem>admin</elem> <elem>supervisor</elem> </list> <param name="grp_2" type="object">#{user_name_list}</param> </allowed_values> </value_extractor_handler> </handlers> <states> <onevent> <rule id="set_user"> <expression><![CDATA[ #{event(value_extractor):command} == 'VALID_EXTRACTION' && exists(#{user_role}) && exists(#{user_name}) ]]></expression> <actions> <setvar id="set_user"> <context_of>workflow</context_of> <context_update> <param name="userrole" type="string">#{user_role}</param> <param name="username" type="string">#{user_name}</param> </context_update> </setvar> </actions> </rule> <rule id="invalid_input"> <expression><![CDATA[ #{event(value_extractor):command} == 'INVALID_EXTRACTION' && #{event:payload.technology} == 'SCAN' ]]></expression> <actions> <ui_notification id="invalid_user" type="ERROR" duration="SHORT" show_immediately="true"> <message>"#{event:payload.code}" is not a valid user!</message> </ui_notification> </actions> </rule> </onevent> </states>