> For the complete documentation index, see [llms.txt](https://docs.fastn.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastn.ai/tutorials-1/understanding-flow-types/how-to-set-up-a-configuration-flow-in-fastn/setting-up-field-level-validation-in-configuration-flows.md).

# Setting up Field-Level Validation in Configuration Flows

To enforce input validation at the field level within your configuration flows, follow these steps:

## **Steps to Enable Field Validation**

1. **Navigate to Your Configuration Flow**\
   Open the specific configuration flow where validation is needed.
2. **Select the Target Step**\
   Click on the step you want to apply validation to.
3. **Open Step Settings**\
   Click on the three-dot menu (`⋮`) associated with the step.

<figure><img src="/files/foYiMakhZCOWLGmqEG9h" alt=""><figcaption></figcaption></figure>

4. Click on **Configure**

<figure><img src="/files/GkMPIDwCvrZMmm72OJNv" alt=""><figcaption></figcaption></figure>

5. **Enable Submit Validation**\
   In the configuration pane, select the **Validation** tab and toggle **Enable Submit Validation**.

<figure><img src="/files/RKA884arzuSIrsT5O5Ac" alt=""><figcaption></figcaption></figure>

## **Validation Script: Empty Field and URL Format Check**

Paste the following JavaScript function into the validator field:

```js
jsCopyEditasync function validator(data = [
  {
    "Channel Name": "",
    "Webhook URL": ""
  }
]) {
  try {
    if (!data || (typeof data !== "object" && !Array.isArray(data))) {
      return { general: "Invalid data format" };
    }

    if (!Array.isArray(data)) {
      return {};
    }

    const errors = data.map((item) => {
      const entryErrors = {};

      const channelName = item["Channel Name"];
      const webhookUrl = item["Webhook URL"];

      if (!channelName || channelName.trim() === "") {
        entryErrors["Channel Name"] = "Channel Name is required";
      }

      if (!webhookUrl || webhookUrl.trim() === "") {
        entryErrors["Webhook URL"] = "Webhook URL is required";
      } else {
        try {
          new URL(webhookUrl); // throws if invalid
        } catch (_) {
          entryErrors["Webhook URL"] = "Invalid URL format";
        }
      }

      return Object.keys(entryErrors).length > 0 ? entryErrors : null;
    });

    return errors.filter((err) => err !== null).length > 0 ? errors : [];
  } catch (error) {
    return { general: "Failed to validate the data" };
  }
}
```

## **After You Add the Script**

* Click **Save.**
* **Redeploy** your configuration flow.

<figure><img src="/files/xfRNZo2nS0r1yHe1OmSM" alt=""><figcaption></figcaption></figure>

## **What This Validator Does?**

* Ensures both **"Channel Name"** and **"Webhook URL"** are not empty.
* Validates that **"Webhook URL"** is in a correct URL format.
* If either field fails, the form will block submission and show appropriate error messages.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fastn.ai/tutorials-1/understanding-flow-types/how-to-set-up-a-configuration-flow-in-fastn/setting-up-field-level-validation-in-configuration-flows.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
