Skip to content

Metafield definition validations

View as Markdown

A Metafield definition validation is a single validation rule on a Metafield definition - for example “max length 500”. It references the metafieldDefinition it belongs to, a name (the validation type), and a value (the rule’s parameter).

The same rules also appear inline as the validations array on a definition. This resource lets you manage them individually - create, update or delete one rule without rewriting the whole definition.

The name must be one of the types that are compatible with the definition’s data type - see Type compatibility. An incompatible rule is rejected with 422.

The Metafield definition validation object

Section titled “The Metafield definition validation object”
PropertyTypeRequiredDescription
idstring-The resource's unique identifier (UUID).
metafieldDefinitionstring | nullrequiredThe metafield definition this validation belongs to Requires the metafields:read scope. Returned null when the scope is missing.
name"/api/metafield_definition_validation_types/min_length" | "/api/metafield_definition_validation_types/max_length" | "/api/metafield_definition_validation_types/min_value" | "/api/metafield_definition_validation_types/max_value" | "/api/metafield_definition_validation_types/max_precision" | "/api/metafield_definition_validation_types/json_schema" | "/api/metafield_definition_validation_types/media_type" | "/api/metafield_definition_validation_types/metaobject_definition"requiredThe type of validation rule
valuestringrequiredThe validation parameter value. Format depends on the validation type.

All requests require an OAuth 2.0 bearer token:

Authorization: Bearer <token>

PATCH uses JSON Merge Patch with Content-Type: application/merge-patch+json.