---
title: List of validation options
description: Learn about the supported validation options for metafields.
source_url:
  html: 'https://shopify.dev/docs/apps/build/metafields/list-of-validation-options'
  md: 'https://shopify.dev/docs/apps/build/metafields/list-of-validation-options.md'
---

# List of validation options

Metafield definitions can have validation options. Validation options enable you to apply additional constraints to the data that a metafield can store, such as a minimum or maximum value, or a regular expression. The type of the metafield definition determines which validation options are available.

***

## How it works

In `shopify.app.toml`, validations use dot notation under the metafield definition. Set properties directly under `validations`:

```toml
[product.metafields.app.summary]
type = "single_line_text_field"
validations.min = 8
validations.max = 100
```

For struct values like weight or dimension constraints, use inline TOML tables:

```toml
[product.metafields.app.package_weight]
type = "weight"
validations.min = { unit = "g", value = 10 }
validations.max = { unit = "g", value = 500 }
```

For validations that accept list values, use TOML arrays:

```toml
[product.metafields.app.flavor]
type = "single_line_text_field"
validations.choices = ["Floral", "Sweet", "Nutty", "Other"]
```

### Graph​QL Admin API syntax

When using the GraphQL Admin API, you include a validation option using a `name` and a corresponding `value` string. The appropriate value depends on the metafield type that the validation applies to. For more information about supported formats and units of measurement available for each type, refer to [metafield types](https://shopify.dev/docs/apps/build/metafields/list-of-data-types).

***

## Supported validation options

The following table describes the validation options available for metafield definitions. Refer to the [examples](#examples) for validation option code snippets.

| Validation option | Description | Supported types | Use cases |
| - | - | - | - |
| [Minimum length](#minimum-length) | Sets the minimum length of a text value | * `single_line_text_field`
* `multi_line_text_field` | - A blog summary needs to be at least 100 characters, so that it provides enough detail.
- A value such as a zip code needs to have an exact character length, so set the minimum and maximum lengths to the same value. |
| [Maximum length](#maximum-length) | Sets the maximum length of a text value | * `single_line_text_field`
* `multi_line_text_field` | - A blog summary or a product description needs to have a maximum length of 150 characters so that it fits in a designated area of your page.
- A value such as a phone number needs to have an exact character length of ten, so set minimum length and maximum length to `10`. |
| [Regular expression](#regular-expression) | Sets a regular expression. Shopify supports [RE2](https://github.com/google/re2/wiki/Syntax). | * `single_line_text_field`
* `multi_line_text_field` | - An email field requires an `@` symbol followed by a `.` and some text.
- A serial number needs to start with a specific set of characters. |
| [Allowed domains](#allowed-domains) | A list of allowed domains. | `url` | * Allow links to specific social media sites at the bottom of an article.
* Allow links to other pages within your site for a list of similar products. |
| [Choices](#choices) | A list of up to 128 predefined options that limit the values allowed for the metafield. The choices value has a maximum of 300,000 characters. | `single_line_text_field` | - The flavor profile field for coffee products allows the following choices: Floral, Sweet, Nutty, and Other.
- The field for sizing fits for a product allows the following choices: True to size, Runs large, Runs small. |
| [File type options](#file-type-options) | Sets a list of file type options. Leaving this empty allows all files, regardless of type. Valid values: `Image`, `Video`. | `file_reference` | * A file reference from a blog to an author photo needs to be to an image file type.
* A file reference to a demonstration video in MP4 format.
* A file reference from an order to product instructions in PDF format. |
| [Maximum precision](#maximum-precision) | Sets the maximum number of decimal places to store for a decimal number | `number_decimal` | - A version number field needs to accept a number with one decimal place.
- A specification field for a product needs to have a maximum of three decimal places. |
| [Minimum date](#minimum-date) | Sets the minimum date in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format | `date` | The date field for an expiry date or a product release needs to be after a specific date. |
| [Maximum date](#maximum-date) | Sets the maximum date in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format | `date` | The date for future product availability can't be later than a specific date. |
| [Minimum datetime](#minimum-datetime) | Sets the minimum date and time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format | `date_time` | A product release occurs on a specific date at midnight, and the product won't display before that date and time. |
| [Maximum datetime](#maximum-datetime) | Sets the maximum date and time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format | `date_time` | A customer loyalty reward expires on a specific date and time. The reward can't be used after that date and time. |
| [Minimum weight](#minimum-weight) | Sets the minimum weight | `weight` | A bundled product weight field needs to have a maximum allowed weight. |
| [Maximum weight](#maximum-weight) | Sets the maximum weight | `weight` | An order requires a minimum weight for shipping. |
| [Minimum volume](#minimum-volume) | Sets the minimum volume | `volume` | * A product volume field needs to have a specific minimum volume.
* A product needs to have an exact volume, so you set minimum volume and maximum volume to the same value. |
| [Maximum volume](#maximum-volume) | Sets the maximum volume | `volume` | - A product volume field needs to have certain maximum volume.
- A product needs to have an exact volume, so you set minimum volume and maximum volume to the same value. |
| [Minimum dimension](#minimum-dimension) | Sets the minimum dimension | `dimension` | A product needs to have a minimum length, width, or height. |
| [Maximum dimension](#maximum-dimension) | Sets the maximum dimension | `dimension` | A product needs to have a maximum length, width, or height. |
| [Minimum integer](#minimum-integer) | Sets the minimum integer number | `number_integer` | A product number needs to be within a specific range of numbers, so you set the minimum and maximum integer validations to create the range. |
| [Maximum integer](#maximum-integer) | Sets the maximum integer number | `number_integer` | A product number needs to be within a specific range of numbers, so you set the minimum and maximum integer validations to create the range. |
| [Minimum decimal](#minimum-decimal) | Sets the minimum decimal number | `number_decimal` | A product version field needs to accept a version number that's greater than a specific decimal number, such as `0.5`. |
| [Maximum decimal](#maximum-decimal) | Sets the maximum decimal number | `number_decimal` | A product version field needs to accept a version number that's less than a specific decimal number, such as `1.99`. |
| [Metaobject definition](#metaobject-definition) | Sets the metaobject definition that a reference must point to | * `metaobject_reference`
* `list.metaobject_reference` | A product refers to a `Designer` metaobject. |
| [Multiple metaobject definitions](#multiple-metaobject-definitions) | Sets the permitted metaobject definitions that can be referred to | - `mixed_reference`
- `list.mixed_reference` | * A product that references a list of different `Material` metaobjects.
* A dynamic placeholder reference that can support a union set of metaobject definitions. |
| [JSON schema](#json-schema) | Sets the permitted JSON format. The [JSON schema](https://json-schema.org/learn/miscellaneous-examples.html) provides an example of a standard way to structure your JSON, and contains information about valid data types and the key descriptions. The JSON schema has a maximum of 300,000 characters. | `json` | Data from a 3rd-party app must match a specific JSON schema. |
| [Product taxonomy attribute](#product-taxonomy-attribute) | Sets the product taxonomy attribute that a reference must point to | - `product_taxonomy_value_reference`
- `list.product_taxonomy_value_reference` | * A product that references a `Color` taxonomy value.
* A product that references a list of `Material` taxonomy values. |
| [List minimum](#list-minimum) | Sets the minimum number of items in a list | Any list type | - A product must have at least two related products.
- A blog post must have at least one tag. |
| [List maximum](#list-maximum) | Sets the maximum number of items in a list | Any list type | * A product can have up to five related products.
* A blog post can have up to 10 tags. |

***

## Examples

This section provides examples of each validation option, in both TOML and GraphQL Admin API formats.

### Minimum length

The following example validates the minimum length of a text value to eight characters.

## shopify.app.toml

##### TOML

```toml
validations.min = 8
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "8"
}]
```

### Maximum length

The following example validates the maximum length of a text value to 25 characters.

## shopify.app.toml

##### TOML

```toml
validations.max = 25
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "25"
}]
```

### Regular expression

The following example validates a regular expression that matches the pattern `(@)(.+)$`.

## shopify.app.toml

##### TOML

```toml
validations.regex = "(@)(.+)$"
```

##### GraphQL Admin API

```yml
validations: [{
  name: "regex",
  value: "(@)(.+)$"
}]
```

### Allowed domains

The following example validates `shopify.com` against a list of allowed domains.

## shopify.app.toml

##### TOML

```toml
validations.allowed_domains = ["shopify.com"]
```

##### GraphQL Admin API

```yml
validations: [{
  name: "allowed_domains",
  value: "[\"shopify.com\"]"
}]
```

### Choices

The following example validates the values allowed for the metafield: `red`, `green`, `blue`.

## shopify.app.toml

##### TOML

```toml
validations.choices = ["red", "green", "blue"]
```

##### GraphQL Admin API

```yml
validations: [{
  name: "choices",
  value: "[\"red\", \"green\", \"blue\"]"
}]
```

### File type options

The following example validates the allowed file type options: `Image`, `Video`.

## shopify.app.toml

##### TOML

```toml
validations.file_type_options = ["Image", "Video"]
```

##### GraphQL Admin API

```yml
validations: [{
  name: "file_type_options",
  value: "[\"Image\",\"Video\"]"
}]
```

### Maximum precision

The following example validates that the maximum number of decimal places to store for a floating-point number is two.

## shopify.app.toml

##### TOML

```toml
validations.max_precision = 2
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max_precision",
  value: "2"
}]
```

### Minimum date

The following example validates the setting for the minimum date in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.

## shopify.app.toml

##### TOML

```toml
validations.min = "2022-01-01"
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "2022-01-01"
}]
```

### Maximum date

The following example validates the setting for the maximum date in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.

## shopify.app.toml

##### TOML

```toml
validations.max = "2022-03-03"
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "2022-03-03"
}]
```

### Minimum datetime

The following example validates the setting for the minimum date and time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.

## shopify.app.toml

##### TOML

```toml
validations.min = "2022-03-03T16:30:00"
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "2022-03-03T16:30:00"
}]
```

### Maximum datetime

The following example validates the setting for the maximum date and time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.

## shopify.app.toml

##### TOML

```toml
validations.max = "2022-03-03T16:30:00"
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "2022-03-03T16:30:00"
}]
```

### Minimum weight

The following example validates a setting for the minimum weight to be ten grams.

## shopify.app.toml

##### TOML

```toml
validations.min = { unit = "g", value = 10 }
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "{\"unit\":\"g\",\"value\":10}"
}]
```

### Maximum weight

The following example validates a setting for the maximum weight to be 50 grams.

## shopify.app.toml

##### TOML

```toml
validations.max = { unit = "g", value = 50 }
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "{\"unit\":\"g\",\"value\":50}"
}]
```

### Minimum volume

The following example validates a setting for the minimum volume to be five milliliters.

## shopify.app.toml

##### TOML

```toml
validations.min = { unit = "ml", value = 5 }
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "{\"unit\":\"ml\",\"value\":5}"
}]
```

### Maximum volume

The following example validates a setting for the maximum volume to be 50 milliliters.

## shopify.app.toml

##### TOML

```toml
validations.max = { unit = "ml", value = 50 }
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "{\"unit\":\"ml\",\"value\":50}"
}]
```

### Minimum dimension

The following example validates a setting for the minimum dimension to be five centimeters.

## shopify.app.toml

##### TOML

```toml
validations.min = { unit = "cm", value = 5 }
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "{\"unit\":\"cm\",\"value\":5}"
}]
```

### Maximum dimension

The following example validates a setting for the maximum dimension to be 50 centimeters.

## shopify.app.toml

##### TOML

```toml
validations.max = { unit = "cm", value = 50 }
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "{\"unit\":\"cm\",\"value\":50}"
}]
```

### Minimum integer

The following example validates a setting for the minimum integer number to be nine.

## shopify.app.toml

##### TOML

```toml
validations.min = 9
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "9"
}]
```

### Maximum integer

The following example validates a setting for the maximum integer number to be 15.

## shopify.app.toml

##### TOML

```toml
validations.max = 15
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "15"
}]
```

### Minimum decimal

The following example validates a setting for the minimum decimal number to be 0.5.

## shopify.app.toml

##### TOML

```toml
validations.min = 0.5
```

##### GraphQL Admin API

```yml
validations: [{
  name: "min",
  value: "0.5"
}]
```

### Maximum decimal

The following example validates a setting for the maximum decimal number to be 1.99.

## shopify.app.toml

##### TOML

```toml
validations.max = 1.99
```

##### GraphQL Admin API

```yml
validations: [{
  name: "max",
  value: "1.99"
}]
```

### Metaobject definition

In TOML, this validation isn't needed because the target definition is specified directly in the `type` field using the [type shorthand syntax](https://shopify.dev/docs/apps/build/metafields/list-of-data-types#declarative-toml-type-syntax). For example:

```toml
[product.metafields.app.designer]
type = "metaobject_reference<$app:designer>"
```

When using the GraphQL Admin API, set the metaobject definition that a reference must point to by ID:

```yml
validations: [{
  name: "metaobject_definition_id",
  value: "gid://shopify/MetaobjectDefinition/123"
}]
```

Or set the metaobject definition by type:

```yml
validations: [{
  name: "metaobject_definition_type",
  value: "app--123456--designer"
}]
```

### Multiple metaobject definitions

In TOML, this validation isn't needed because the permitted definitions are specified directly in the `type` field using the [type shorthand syntax](https://shopify.dev/docs/apps/build/metafields/list-of-data-types#declarative-toml-type-syntax). For example:

```toml
[product.metafields.app.content_block]
type = "mixed_reference<$app:author, $app:publisher>"
```

When using the GraphQL Admin API, set the permitted metaobject definitions that can be referred to by ID:

```yml
validations: [{
  name: "metaobject_definition_ids",
  value: "[\"gid://shopify/MetaobjectDefinition/123\",\"gid://shopify/MetaobjectDefinition/456\"]"
}]
```

Or set the permitted metaobject definitions by type:

```yml
validations: [{
  name: "metaobject_definition_types",
  value: "[\"app--123456--author\",\"app--123456--publisher\"]"
}]
```

### JSON schema

The following example validates a setting for the permitted JSON format.

## shopify.app.toml

##### TOML

```toml
validations.schema = '{"$id":"https://example.com/person.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","title":"Person","type":"object","properties":{"firstName":{"type":"string"},"lastName":{"type":"string"},"age":{"type":"integer","minimum":0}}}'
```

##### GraphQL Admin API

```yml
validations: [{
  name: "schema",
  value: "{
    \"\$id\": \"https://example.com/person.schema.json\",
    \"\$schema\": \"https://json-schema.org/draft/2020-12/schema\",
    \"title\": \"Person\",
    \"type\": \"object\",
    \"properties\": {
        \"firstName\": {
            \"type\": \"string\",
            \"description\": \"The person's first name.\"
        },
        \"lastName\": {
            \"type\": \"string\",
            \"description\": \"The person's last name.\"
        },
        \"age\": {
            \"description\": \"Age in years >= 0.\",
            \"type\": \"integer\",
            \"minimum\": 0
        }
    }
}"
}]
```

### Product taxonomy attribute

The following example validates a setting for the product taxonomy attribute that a reference must point to.

## shopify.app.toml

##### TOML

```toml
validations.product_taxonomy_attribute_handle = "style"
```

##### GraphQL Admin API

```yml
validations: [{
  name: "product_taxonomy_attribute_handle",
  value: "style"
}]
```

### List minimum

The following example validates that a list must contain at least two items.

## shopify.app.toml

##### TOML

```toml
[product.metafields.app.tags.validations]
"list.min" = 2
```

##### GraphQL Admin API

```yml
validations: [{
  name: "list.min",
  value: "2"
}]
```

### List maximum

The following example validates that a list can contain up to five items.

## shopify.app.toml

##### TOML

```toml
[product.metafields.app.tags.validations]
"list.max" = 5
```

##### GraphQL Admin API

```yml
validations: [{
  name: "list.max",
  value: "5"
}]
```

***

## Next steps

* Learn how to [work with metafield definitions](https://shopify.dev/docs/apps/build/metafields/definitions).
* Learn about [metafield data types](https://shopify.dev/docs/apps/build/metafields/list-of-data-types).
* Learn how to [enable filtering and other advanced features](https://shopify.dev/docs/apps/build/metafields/use-metafield-capabilities).

***
