The function FIRST_VALIDATION takes an Object in which every property contains a List of strings, and returns the first string in the List contained by the specified property.
This function is intended to be used in tandem with the Form Web Control. It takes the Object defined by the Trigger Form Validation Action and uses it to define the dynamic error messages in the Form. Error messages cluster by Model property, and FIRST_VALIDATION is used to pull error messages to display accordingly.
Declaration
FIRST_VALIDATION(form_object, property_name) -> error_message
Parameters
form_object (required, type: Object)
An Object in which every property contains a List of strings.
An Object with this structure is automatically generated upon the creation of a Form Web Control. It is configured such that its value is dynamically updated by the Trigger Form Validation Action.
property_name (required, type: string)
A string that corresponds to a property in the given Object.
Return Values
error_message (type: string)
The first string listed in the List associated with the designated property_name in the form_object.
Examples
Assume all of our examples have access to the following variable, example_form
. Note that example_form
is Object in which every property contains a List of strings:
example_form -> {
"name_validation_rule": [
"Your name can not be over thirty characters long.",
"Please enter both your first and last name, with a space between them."
],
"email_validation_rule": null,
"phone_validation_rule": [
"Your phone number is required."
]
}
The following example returns the first string in the List stored under the "name_validation_rule"
property in Object example_form
. Note that while there are multiple strings stored in this List, only the first one is returned:
FIRST_VALIDATION(example_form, "name_validation_rule") ->
"Your name can not be over thirty characters long."
The following example returns the first and only string in the List stored under the "phone_validation_rule"
property in Object example_form
:
FIRST_VALIDATION(example_form, "phone_validation_rule") -> "Your phone number is required."
The following example returns an empty string, because there are no strings contained in the in the List stored under the "email_validation_rule"
property in Object example_form
:
FIRST_VALIDATION(example_form, "email_validation_rule") -> ""
An empty string will also be returned by the FIRST_VALIDATION function if the value given for the property_name does not correspond with a property in the given Object:
FIRST_VALIDATION(example_form, "not_a_form_property") -> ""