validate_form_data (GET)
Purpose
Check that the configuration data for a function provided by the user via the function configuration form is valid.
Input parameters
- id: Identifier of the function that owns the form, as returned by the get_function_info command in the id parameter.
- data: A JSON object with the following format:
{ "language":"en", "trigger_output_vars":{ "from":"text", "send_date":"date", "amount":"decimal", "var1":"custom1" } "authentication":{ "user_id":"theUser", "auth_saved_data":"..." }, "form_data":{ "city":"Tokyo", "time":"12:34" } }
- language: The language in which the errors messages should be returned if the data is not valid. If the application does not support this language, messages should be returned in English.
- trigger_output_vars: This element will be supplied only if the function is an action. It contains the names and types of the output variables produced by the trigger of the same task.
- authentication: This element will be supplied only if the application requires authentication and the user has already authenticated at least once for the function in the current task. Contains the information about the currently authenticated user, as in the element of the same name passed to the process_trigger and do_action commands.
- form_data: The state of the function configuration form input controls when the command is invoked, as set by the user in the control panel for the current task.
Output data
A JSON object with this format:
{ "data_is_valid":"false", "error_messages":[ "City cannot be empty", "Time must be in hh:mm format" ] }
- data_is_valid: True if all the data in the form is valid, false otherwise. If true, the rest of the JSON object is ignored by Botize.
- error_messages: An array of strings where each item is a one-line error message to be displayed to the user, in the language specified in the language element of the input data.
Notes
Botize will invoke this command when the user saves a task where the trigger, the action or both have a configuration form; the command will be invoked once for each function that has a form. The command code must check if the data on the form_data element is valid (optionally checking the contents of the trigger_output_vars and authentication elements too) and compose the response JSON object appropriately. If the command returns data_is_valid = false, the task saving process will be aborted and the returned error messages will be displayed to the user.