Validate Dialog Input Value

You can assert that input fields in a dialog can only have specific values. AWM provides two possible solutions for this requirement.

The first solution is to specify a Retrieve All Values action for a property. If the property is defined in an AWM tool Open Modeled Dialog it is displayed as a selection list followed by a Retrieve button. Clicking Retrieve executes the Retrieve All Values action. This selects the values in the list that you have specified for the property.

The second solution is to specify a Validate Action for an AWM tool Open Modelled Dialog. The validate action can contain one or more tools which validate the properties specified in the dialog box.

You can write custom scripts to check one or more dialog properties if there are, for example, dependencies between the properties being checked. You must ensure that the tools generate error messages of an appropriate severity. See Validate Action for more information. The tool's messages are processed and evaluated by the validate action. If there is at least one error message supplied by a tool of the validate action the dialog box is not closed when you click OK.

The tool Validate Value is provided within the AWM function package. You can use it for simple validation, for example, to validate a property values against regular expressions. So that an input field conforms with a specific naming convention.

Example

The following example dialog box contains a Department, Project, and Development Environment field. The Department field has a corresponding Retrieve button. When you click Retrieve it fetches all the values for a department of a company. In addition, the AWM tool Open Modelled Dialog has a validation action which points to two validation tools. One for the property Project and one for the property Development Environment.

The property Department is modeled with a Retrieve All Values action:


Retrieve All Values

This action calls a tool which returns a file descriptor with just one property. The file created by the tool contains all the valid values for the Department. Each Department in a separate line in the file.

The modelling of the tools looks like this:


Tool Modeling

The Message Severity for the validation tools has been modeled as an Error. The Message Type for the validation tool has been modeled as Validation Message:


Validation Tool

The Regex field specifies a regular expression that is used to validate the Project name. In this case, it accepts upper and lower case letters, numbers, #, and $. In addition, the project name must be between 1 and 16 characters long.

The validation action is modeled as follows:


Validation Action

At execution the dialog box looks like:


Create Project Dialog

You can select a Department once you have clicked Retrieve. If the values in the Project and Development Environment fields do not match their corresponding regular expressions then error markers are displayed along with any modeled validation message:


Dialog Execution