☁️ Loving our new documentation website? Provide feedback in the CloudCannon Community! ✨

pattern

Table of contents

Description:

This key defines a regular expression that the Input value must match.

When configured, CloudCannon will require you to enter a value that matches the REGEX pattern.

If the Input already contains an invalid value, CloudCannon will require you to enter a valid string to save your changes, or discard your unsaved changes.

Value must be a valid REGEX string.

If your REGEX string includes a \ character and CloudCannon Configuration File is a .yml file, use single quotes ' around the string to avoid a build error.

This key has no default.

This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.

To use this key in a Select Input, allow_create must be set to true.

Appears in:
└── _inputs
    └── *
        ├── Text Input
        │   └── options
        │       └── pattern
        ├── Textarea Input
        │   └── options
        │       └── pattern
        ├── Code Input
        │   └── options
        │       └── pattern
        ├── Color Input
        │   └── options
        │       └── pattern
        ├── Rich Text Input
        │   └── options
        │       └── pattern
        ├── File Input
        │   └── options
        │       └── pattern
        ├── URL Input
        │   └── options
        │       └── pattern
        ├── Select Input
        │   └── options
        │       └── pattern
        └── Choice Input
            └── options
                └── pattern
Type:
string
Examples:

In this example, we want our team to add an email address to the contact_email Input using the correct email format.

Copied to clipboard
_inputs:
  contact_email:
    type: email
    options:
      pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
      pattern_message: Please use the format ___@___.__
{
  "_inputs": {
    "contact_email": {
      "type": "email",
      "options": {
        "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
        "pattern_message": "Please use the format ___@___.__"
      }
    }
  }
}
Open in a new tab