> For the complete documentation index, see [llms.txt](https://docs.thewalletcrew.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thewalletcrew.io/guides-enrolment/enrolment/enrolment-form/validation-rules.md).

# Validation rules

Configure enrolment form validation rules for required, format, and matching checks.

Validation rules protect data quality at the point of capture. They prevent incomplete or incorrectly formatted values from entering customer profiles and downstream systems.

Choose rules based on the purpose of each field. Strict validation is useful for identifiers. Optional enrichment fields should remain easy to complete. To block automated submissions, see [Cloudflare Turnstile](https://docs.thewalletcrew.io/guides-enrolment/enrolment/enrolment-form/validation-rules/cloudflare-turnstile.md).

## How validation works

Validation is configured at the individual field level, in the form definition: use the form's **Advanced** tab (YAML). Each field under `form.fields` can be marked `required: true`, and text fields (`textbox`, the default field type) accept a `validators` list. Each rule checks whether a value meets the data requirements before the form is submitted.

```yaml
form:
  fields:
    - name: email
      required: true
      validators:
        - type: email
    - name: emailConfirmation
      validators:
        - type: equality
          target: email
    - name: postalCode
      validators:
        - type: regex
          regex: "^[0-9]{5}$"
```

Use a small number of rules that match the field’s purpose. Overly restrictive forms can increase abandonment and create support work.

## Available validation rules

### `required: true` (field property)

* Indicates whether the field must be filled out. It is a property of the field, not an entry of `validators`. Default `false`.
* For checkboxes and switchboxes, this means the box must be checked.

### `email`

* Combines two layers of validation:
  1. **Regular Expression Check**: Uses the following default regex to validate format:

     ```js
     /^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/
     ```

     This regex can be **overridden** with the validator's `regex` property.
  2. **Domain Check via DNS**: The Wallet Crew verifies that the email domain accepts mail by checking for **MX records**. This check only shows a warning and does not block the form. Set `verifyEmail: false` to turn it off (default `true`).

### Phone fields (`type: phonebox`)

* Phone numbers are captured with a `phonebox` field, not with a validator.
* It validates numbers with the [react-phone-number-input](https://catamphetamine.gitlab.io/react-phone-number-input/) component, based on Google’s international phone number validation library.
* Ensures numbers are correctly formatted and country codes are recognized.

### `regex`

* Validates the field against a **custom regular expression**, set in the validator's `regex` property.
* Flexible option for enforcing format-specific data (e.g., postal codes, IDs).

### `equality`

* Compares the field’s value to another field, named in `target` (e.g., "Confirm email").
* Ensures consistency and matching where required.

## Configure rules effectively

Test custom regular expressions with expected and invalid values before publishing.

{% hint style="warning" %}
Customize the default email expression only when there is a documented requirement. An overly narrow expression can reject valid customer email addresses.
{% endhint %}

## Validate the form before publishing

Submit the form with representative valid and invalid values. Confirm that required fields block empty submissions, format rules show clear errors, and equality fields reject mismatched values.

Review the result on mobile as well as desktop. Most enrolment journeys begin on a phone after a QR-code scan or campaign link.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.thewalletcrew.io/guides-enrolment/enrolment/enrolment-form/validation-rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
