Component Validation

To enable input validation, specify the type of input (e.g., string, number, etc.). The system defines regex based on the input type, or you can use a custom regex along with a custom error.

Uses

  • type: The type of input.
  • reg_ex: If you want to use a custom regex, it will override the type.
  • field_error: An error message required in case validation fails.

Outputs

If there are validation errors, the component will throw an error; otherwise, it will work as expected.

Example

{
  "component_name": "form_builder",
  "pages": [
    {
      "header": "Create / Edit an Action",
      "instructions": "Fill out the form below to create or edit an action.",
      "fields": [
        {
          "id": "name",
          "title": "Action Name",
          "component": "text_input",
          "instructions": null,
          "type": "string", // Use default regex if needed
          "required": true,
          "reg_ex": "^[a-zA-Z]+$", // Use custom regex if needed
          "field_error": "Invalid string"
        }
      ]
    }
  ],
  "data_token": {
    "request.text_input": "text_input"
  }
}

Note: The example demonstrates the usage of the validation in text_input component