# Validation – Form Builder

The rules each field type supports, custom patterns and error messages.

Each field has a **Required** setting, and some types have more rules. The **Preview** tab runs the rules so you can test them. Your website enforces them for real: see [Validation with Zod](https://contentful.geeconglobal.com/apps/form-builder/docs/validation-with-zod).

## Rules by field type

| Type                    | Rules                                                                                      |
| ----------------------- | ------------------------------------------------------------------------------------------ |
| Short text              | Required, minimum length, maximum length, allowed characters or a custom pattern          |
| Long text               | Required, minimum length, maximum length                                                   |
| Email                   | Required. The format is always checked                                                     |
| Phone                   | Required, minimum digits (default 10), maximum digits (default 15). A leading `+` is fine |
| Number                  | Required, minimum, maximum, whole numbers only                                             |
| Web address             | Required. It must start with `http://` or `https://`                                       |
| Date                    | Required, earliest date, latest date (`YYYY-MM-DD`, or `today`)                            |
| Time                    | Required, earliest time, latest time                                                       |
| Dropdown, Radio buttons | Required                                                                                   |
| Checkboxes              | Required, minimum choices, maximum choices                                                 |
| Yes/No                  | Required means the answer must be yes                                                      |
| Consent                 | Required means it must be ticked                                                           |
| Hidden                  | None                                                                                       |

Where a minimum and a maximum are both set, the builder reports an error if the minimum is larger.

## Allowed characters and custom patterns

A Short text field can limit what people type: **Letters only**, **Numbers only**, **Letters and numbers**, or a **Custom regular expression**. The builder checks that a custom expression is valid. Long text has no patterns.

## Error messages

Each rule has a message. Your website looks for the field's own message first, then the form-wide message for that rule. So you can write one clear default and override only the odd one.

- **Field message:** set in the field's settings under **Error messages**, and stored as `<fieldId>.errors.<rule>`.
- **Form-wide message:** set in the app configuration under **Default texts**. New forms copy these, so each form keeps its own copy.

A message can include `{limit}`, which your website replaces with the limit, as in `Enter at least {limit} characters`. Messages are translated like any other text. See [Translations](https://contentful.geeconglobal.com/apps/form-builder/docs/translations).

The **error summary**, a title and a line of text shown above the fields after a failed submit, is set in the **Settings** tab.
