- Help center home
- Getting started
- Content model
- Managing content
- Working with entries
- Working with media
- Working with translations
- Managing users
- Roles
- Account settings
- Administration
- Content orchestration
- Compose
- Launch
- Workflows
- How to get help and support
- Guides
- Contentful certification
- Contentful glossary
- Manage cookie consent
- Apps
- Usage Limit
- Marketplace
Available validations
On this page
Contentful stores user input as structured data and. The validations you can apply to a field depend on the field type. The table below lists the available validations and indicates which field types you can use them with.
Name | Description | Field type |
---|---|---|
Size
Validates that the size of a text, object or symbol entry is within a specified range. You can define a range by specifying the ‘min’ and the ‘max’ values (the values are included in the range). Alternatively, you can specify only the ‘min’ or ‘max’ value to set a constraint on a the minimum/maximum allowed value.
Predefined values
Validates that the value of a field belongs to a predefined set. To define a set, add the desired values one by one. Note that currently there is a limit of 50 predefined values you can define. By default, the predefined values will be displayed in the entry editor as a drop-down list.
Regular Expression (Regex)
Validates that the value of a field matches a specific pattern defined by a regular expression. You can further modify pattern matching by including optional flags, such as return all matches (‘g’), perform case-insensitive (‘i’) or multi-line (‘m’) search. Consult JavaScript Regular Expressions for more information on constructing valid regular expressions.
For users’ convenience, Contentful validations module provides a number of predefined regex rules covering mainstream scenarios.
An email consist of a user name, followed by ‘@’ followed by a domain name. Characters allowed in a user name are alphanumeric characters (a-z, 0-9), ‘_’, ‘.’, ‘-’. The same holds for domain names.
Allowed values | Disallowed values |
---|---|
URL
A valid URL requires a protocol prefix (ftp, http, https) and a top-level domain.
Allowed values | Disallowed values |
---|---|
Date (US)
Dates in the format ‘MM/DD/YYYY’ where each character represents a digit. Single-digit months and days may or may not have a leading zero. The year may have two or four digits. Please note that only dates after 1900 are allowed.
Allowed values | Disallowed values |
---|---|
Date (European)
Dates in the format ‘DD/MM/YYYY’. The same restrictions as for the US dates apply.
Allowed values | Disallowed values |
---|---|
Phone number (US)
Format ‘X-XXX-XXX-XXXX’ or ‘X-(XXX)-XXX-XXXX’ where each X is a digit. Dots (‘.’) and a single whitespace are also accepted as separators instead of ‘-’. The separators may be omitted.
Allowed values | Disallowed values |
---|---|
US zip code
Accepts zip codes entered as five digits (‘XXXXX’) or five plus four digits ‘XXXXX-XXXX’.
Allowed values | Disallowed values |
---|---|
Time (12 hrs)
Accepts time values in the HH:MM:SS AM/PM format. Allowed hours are from 01 to 12, columns are required, while the use of seconds is optional. The input must contain AM/PM notation in either lower- or upper-case.
Allowed values | Disallowed values |
---|---|
Time (24 hrs)
Accepts time values in the HH:MM:SS format. Allowed hours are from 01 to 24, columns are required, while the use of seconds is optional. The input cannot contain AM/PM notation.
Allowed values | Disallowed values |
---|---|
Range
Validates that the value of a number field is within a specified range. You can use integers or decimal numbers to define the range and negative numbers are also accepted. Alternatively, you can define only the maximum or minimum value.
Date Range
Validates that the value of a date field is within a specified range. In addition to the date, the range requires time values, set these to 00:00 when the time value is optional.
Please note that for storing time values without a date, we recommend using a relevant Regex rule with a Symbol or Text field type.
Number of items
Validates that the number of symbols/ entries / assets is within a specified range. Only integers are allowed as input values.
File size
Validates that the size of an asset is within a specified range. Please note that the entered values are stored as bytes, but displayed as Bytes / Kb / Mb.
Image dimensions
Validates that the dimensions of an image are within a specified range. The entered values are interpreted as pixels and are inclusive of the range. Alternatively, you can specify only a desired height or width.
Please note that the validation will only be applied to assets that are identified as images.
Type
Validates that the attached entry / uploaded asset is of the specified type. The types of entries are based on content types available within a space. Asset types are based on MIME groups and include:
Attachment
Plain text
Image
Audio
Video
Rich text
Presentation
Spreadsheet
PDF document
Archive
Code
Markup
Please consult Wikipedia page for the list of file types corresponding to specific MIME types.