---
canonical: https://amplience.com/developers/docs/schema-reference/validation/
title: Validation

description: Use the Amplience schema reference validation keywords to define rules for the valid values that authors can enter for properties when creating content.
audience: Developer
date_published: 2022-07-12
date_modified: 2026-05-10
---

# Validation

The values authors can enter for a specific property can be constrained using validation keywords.

These validation keywords can be used individually or combined.

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      //highlight-start
      "minLength": 0,
      "maxLength": 50
      //highlight-end
    }
  },
  //highlight-start
  "required": ["name"]
  //highlight-end
}
```

They can be used anywhere a value type is defined in the schema, including properties and array items.

```json
{
  "type": "array",
  "items": {
    "type": "string",
    //highlight-start
    "minLength": 0,
    "maxLength": 50
    //highlight-end
  }
}
```

Below is a summary of the available validation keywords

| Validation Type                             | Description                                                                                                                                                                       |
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Enumerated values](#enumerated-values)     | Restricts the value to a fixed set of possible values. Properties using this validation will display as a dropdown.<br />`{"enum": ["red", "blue", "green"]}` `{"enum": [1,2,3]}` |
| [Constant values](#constant-values)         | Restricts the value to a constant value. Users will be unable to change the value in the authoring interface.<br />`{"const": "BannerComponent"}`                                 |
| [Regular expression](#regular-expression)   | Validates the format of text values matches a custom regular expression<br />`{"pattern": "[a-z]+"}`                                                                              |
| [Text minimum length](#text-minimum-length) | Validates the minimum length of a text value<br />`{"minLength": 1}`                                                                                                              |
| [Text maximum length](#text-maximum-length) | Validates the maximum length of a text value<br />`{"maxLength": 50}`                                                                                                             |
| [Text format](#text-format)                 | Validates the format of text values matches the specified built-in format<br />`{"format": "date"}` see [below](#text-format) for a full list of formats                          |
| [Number minimum value](#minimum-value)      | Validates that the value entered is more than or equal to the minimum value.<br />`{"minimum": 0}` or `{"exclusiveMinimum": 0}` for just more than                                |
| [Number maximum value](#maximum-value)      | Validates that the value entered is less than or equal to maximum value.<br />`{"maximum": 10}` or `{"exclusiveMaximum": 0}` for just less than                                   |
| [Number multiple](#multiple)                | Validates that the value entered is a multiple of the multipleOf value<br />`{"multipleOf": 2}`                                                                                   |
| [Required properties](#required-properties) | Validates that the specified properties must be populated.<br />`{"properties": {"name": {"type": "string"}}, "required": ["name"]}`                                              |
| [Array minimum items](#array-minimum-items) | Validates that the Array value contains at least the minimum number of items<br />`{"minItems": 1}`                                                                               |
| [Array maximum items](#array-maximum-items) | Validates that the Array value does not contain more than the maximum number of items<br />`{"maxItems": 1}`                                                                      |
| [Array unique items](#array-unique-items)   | Validates that every item in the Array is unique<br />`{"uniqueItems": true}`                                                                                                     |

## Generic

### Enumerated values

```json
{ "type": "string", "enum": ["small", "medium", "large"] }
```

`✅ "small"`
`❌ "xlarge"`

```json
{ "type": "number", "enum": [2, 4, 8, 16] }
```

`✅ 2`
`❌ 3`

The `enum` keyword restricts the values users can select to a fixed list.

Properties using this validation will display as a dropdown.

### Constant values

```json
{
  "properties": {
    "component": { "type": "string", "const": "BannerComponent" }
  }
}
```

The `const` keyword can be applied to any property to hard-code the value.

Properties using this keyword will be automatically set to the `const` value and will be immutable.

## Strings

### Regular Expression

```json
{ "type": "string", "pattern": "^[a-zA-Z0-9_-]+$" }
```

`✅ "summer-sale"`
`❌ "summer sale"`

The `pattern` keyword can be applied to any `string` property to validate the value matches a custom regular expression.

The `pattern` keyword must be a valid ECMA-262 regular expression.

### Text Minimum Length

```json
{ "type": "string", "minLength": 10 }
```

`✅ "hello world"`
`❌ "hello"`

The `minLength` keyword can be applied to any `string` property to validate the number of characters is greater than, or equal to, the value of the keyword.

### Text Maximum Length

```json
{ "type": "string", "maxLength": 10 }
```

`✅ "hello"`
`❌ "hello world"`

The `maxLength` keyword can be applied to any `string` property to validate the number of characters is less than, or equal to, the value of the keyword.

### Text Format

```json
{ "type": "string", "format": "date" }
```

The `format` keyword can be applied to any `string` property to validate common data formats that do not have a native JSON representation.

The supported formats are detailed below:

| Format                    | Description                                                                                                                |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `"color"`                 | RGB or RGBA color, e.g. `"rgb(255,255,255)"`. Will display as a color picker.                                              |
| `"date"`                  | [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339#section-5.6) Date e.g. `"2018-11-20"`                                    |
| `"time"`                  | [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339#section-5.6) Time e.g. `"20:20:39"` or `"20:20:39+00:00"`                |
| `"date-time"`             | [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339#section-5.6) Date-time e.g. `"2018-11-13T20:20:39+00:00"`                |
| `"markdown"`              | Markdown rich text, e.g. `"# Heading 1"`. Will display as a rich text editor.                                              |
| `"uri"`                   | [RFC 3986](https://tools.ietf.org/html/rfc3986) URI, e.g. `"https://example.com/"`                                         |
| `"uri-reference"`         | [RFC 3986](https://tools.ietf.org/html/rfc3986#section-4.1) URI Reference, e.g. `"../page"`                                |
| `"uri-template"`          | [RFC 6570](https://tools.ietf.org/html/rfc6570) URI template, e.g. `"http://example.com/search{?q,lang}"`                  |
| `"email"`                 | [RFC 5321](https://tools.ietf.org/html/rfc5321#section-4.1.2) Internet email address, e.g. `"example@example.com"`         |
| `"hostname"`              | [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123#section-2.1) Hostname, e.g. `"example.com"`                       |
| `"ipv4"`                  | [RFC 2673](https://tools.ietf.org/html/rfc2673#section-3.2) V4 IP Address, e.g. `"192.168.16.1"`                           |
| `"ipv6"`                  | [RFC 2373](https://tools.ietf.org/html/rfc2373#section-2.2) V6 IP Address, e.g. `"1080:0:0:0:8:800:200C:417A"`             |
| `"json-pointer"`          | [RFC 6901](https://tools.ietf.org/html/rfc6901) JSON Pointer, e.g. `"/foo/bar"`                                            |
| `"relative-json-pointer"` | [Relative JSON Pointer](https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01), e.g. `"0#"`                  |
| `"regex"`                 | [ECMA 262](https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) Regular expression, e.g. `"[a-z]+"` |

## Numbers

### Minimum value

```json
{ "type": "number", "minimum": 0 }
```

`✅ 0`
`❌ -1`

```json
{ "type": "number", "exclusiveMinimum": 0 }
```

`✅ 1`
`❌ 0`

The `minimum` keyword can be applied to any `number` property to validate the value is greater than, or equal to, the value of the keyword.

The `exclusiveMinimum` keyword can be applied to any `number` property to validate the value is greater than the value of the keyword.

### Maximum value

```json
{ "type": "number", "maximum": 100 }
```

`✅ 100`
`❌ 101`

```json
{ "type": "number", "exclusiveMaximum": 100 }
```

`✅ 99`
`❌ 100`

The `maximum` keyword can be applied to any `number` property to validate the value is less than, or equal to, the value of the keyword.

The `exclusiveMaximum` keyword can be applied to any `number` property to validate the value is less than the value of the keyword.

### Multiple

```json
{ "multipleOf": 2 }
```

`✅ 4`
`❌ 3`

The `multipleOf` keyword can be applied to any `number` property to validate the value is a multiple of the value of the keyword.

## Objects

### Required Properties

```json
{
  "type": "object",
  "properties": {
    "title": { "type": "string" },
    "sku": { "type": "string" }
  },
  "required": ["title", "sku"]
}
```

`✅ {"title": "Summer Dress", "sku": "xa83748"}`
`❌ {"title": "Summer Dress"}`
`❌ {"sku": "xa83748"}`

The `required` keyword can be applied to any `object` property to validate the specified properties are populated.

The `required` keyword must be an array containing a unique set of property names, which must correspond to a property defined in the `properties` object.

## Arrays

### Array minimum items

```json
{
  "type": "Array",
  "items": { "type": "string" },
  "minItems": 2
}
```

`✅ ["item 1", "item 2", "item 3"]`
`✅ ["item 1", "item 2"]`
`❌ ["item 1"]`

The `minItems` keyword can be applied to any `array` property to validate the length of the array is greater than, or equal to, the value of the keyword.

### Array maximum items

```json
{
  "type": "Array",
  "items": { "type": "string" },
  "maxItems": 2
}
```

`✅ ["item 1"]`
`✅ ["item 1", "item 2"]`
`❌ ["item 1", "item 2", "item 3"]`

The `maxItems` keyword can be applied to any `array` property to validate the length of the array is less than, or equal to, the value of the keyword.

### Array unique items

```json
{
  "type": "Array",
  "items": { "type": "string" },
  "uniqueItems": true
}
```

`✅ ["item 1", "item 2"]`
`❌ ["item 1", "item 1"]`

The `uniqueItems` keyword can be applied to any `array` property to validate the items inside the array are unique.

### Array contains

Contains allows you to specify that an array must contain at least one item that matches specified schema. This can include a number which is greater than or equal to a specified amount, a string greater than a specified length, or a string equal to a value defined in a `const`.

The example below shows the use of `contains` to validate two array properties.

```json
"properties": {
		"numberArray": {
			"title": "Number array",
			"description": "An array of numbers",
			"type": "array",
			"minItems": 0,
			"maxItems": 10,
			"items": {
				"type": "number"
			},
			"contains":
				{
					"type": "number",
					"minimum": 10
				}
		},
		"stringArray": {
			"title": "String array",
			"description": "An array of strings",
			"type": "array",
			"minItems": 0,
			"maxItems": 10,
			"items": {
				"type": "string"
			},
			"contains":
				{
					"type": "string",
					"minLength": 10
				}
		}
	}
```
