Fetch Validation Rule
A rule definition when complex validation is required.
A fetch validation rule defines what rule definition will be used to validate the fetch’s data and how failed validation is handled on the Agentry Client. The rule referenced is called in a Boolean context and is expected to return true or false. False indicates failed validation, which may be treated as a warning or error. Messaging may be displayed to the user in relation to failed validation. An error requires the user to change the offending value(s) before proceeding. A warning displays an informational message giving the user the option to change the value(s), but does not require a change.
Not every fetch will have validation rules. Certain types of values do not need to be validated using a validation rule. Simple requirements such as the size of a string value or the minimum and maximum values of a numeric property can be enforced by the property itself. In other cases the data may simply not need to be validated.
Validation rules are used when more complex validation is required, such as when the valid value for a property is dependent on the value of a second property. Also, validation rules offer the flexibility to differentiate between a warning and an error. With a warning, the user is given the option of changing the value that violates the rule or leaving it as is. If treated as an error, the user must change the value before being allowed to proceed.
Validation rules are evaluated when the user clicks any navigation buttons in the wizard screen set displaying the fetch. If a validation rule references a property not yet displayed in the wizard, it will not fail validation. A false return by the rule is treated as a validation failure and the validation rule definition will then dictate the behavior of the Client.
Validation Rule Attributes
- Rule: This attribute specifies the rule definition within the same module to be used as a validation rule for the fetch. The rule is expected to return a Boolean value in the context of the current fetch instance.
- Type: This attribute can be set to either “Warning” or “Error” and determines how a false return from the rule is treated by the validation rule. Warning means a failed validation does not require the user to change the value. The user will be displayed a message and given the option to change the value or keep it as set. An error type requires the user to change the value before proceeding.
- Caption: This is the text displayed in the title bar of the message for the validation rule.
- Text: This is the message displayed to the user when validation fails.
- OK Label: This is the text to label the OK button for the message screen on the client.
- Cancel Label: This is the text to label the Cancel button for the message screen on the client. This attribute is available only when the Type attribute is set to “Warning”.