The validation script returns a JavaScript object that contains a property named “success”. If the script returns a Boolean value or a non-Boolean object (for example, Number or String), then its value is converted to Boolean using standard JavaScript conversion rules and then assigned to the success property. The script can optionally return a JavaScript array of values in a property named parameters. The array values are substituted into the failure message of the validation using string substitution.
You can return a Boolean value (True or False). If you return True, the validation succeeds; otherwise it fails. If you do not return a value, it is considered the same as returning False.
If you return a non-Boolean object, such as Number or String, it is converted to Boolean then returned. Standard JavaScript conversion applies. Numbers equal to zero, empty strings, and null or undefined objects are interpreted as false. All other values are true.
If you return a complex object that contains a property named “success,” that success property is converted to Boolean and used as the return value of the validation. You can optionally return an Array of values in a property named “parameters.” This is a JavaScript Array object, that needs to be populated and then used in the parametrized Failure Message. The parameters are substituted into the failure message of the validation using string substitution. You should return the correct number of values corresponding to the placeholders in the failure message. If you return extra parameters they are ignored. If you do not return enough parameters, the missing parameters are considered empty strings.