Schema validation reference for legacy object types

You can use the Validate Legacy Object Types endpoint to validate the schema of your object types. This article explains the validation error messages returned by the endpoint.

The schema for a legacy object type cannot be empty.

The schema is empty.

{  "data": {    "key": "product",    "schema": {}  }}

The properties element of a schema cannot be empty.

The schema's properties property is empty.

{  "data": {    "key": "product",    "schema": {      "properties": {}    }  }}

data.schema object has missing required properties (["properties"])

The schema does not have a properties property, which is mandatory.

{  "data": {    "key": "product",    "schema": {      "foo": "bar"    }  }}

additionalProperties cannot be set to true

The schema contains the additionalProperties property and the value for that property is set to true.

{  "data": {    "key": "product",    "schema": {      "properties": {        "id": {          "type": "string"        }      },      "additionalProperties": true    }  }}

data.schema object has missing required properties (["type"])

The schema defines a property but does not specify a type for the property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "id": {          "description": "ID of the product"        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["$schema"]

The schema defines the JSON schema version to be used to validate the input schema. Since legacy custom objects use their own custom schema, this property is not supported.

{  "data": {    "key": "product",    "schema": {      "$schema": "http://json-schema.org/draft/2019-09/schema#",      "properties": {        "id": {          "type": "string"        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["patternProperties"]

The schema defines a patternProperties object.

{  "data": {    "key": "product",    "schema": {      "patternProperties": {        "^[a-zA-Z0-9]*$": {          "properties": {            "name": {              "type": "string",              "maxLength": 10            }          }        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["$ref"]

The schema defines a property and the definition of that property use a JSON pointer reference.

{  "data": {    "key": "product",    "schema": {      "properties": {        "id": {          "$ref": "#/definitions/IdObject"        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["definitions"]

This error is thrown when the schema of the legacy object type defines a JSON Schema definition for the IdObject which is not supported.

{

"data": {
    "key": "product",
    "schema": {
        "definitions": {
            "IdObject": {
                "type": "string",
            }
        },
        "properties": {
            "id": {
                "$ref": "#/definitions/IdObject"
            }
        }
    }
}

}

data.schema object instance has properties which are not allowed by the schema: ["dependencies"]

The schema defines a dependencies object for a property, such as the credit_card property in the example below.

{  "data": {    "key": "product",    "schema": {      "properties": {        "credit_card": {          "type": "number"        },        "billing_address": {          "type": "string"        }      },      "dependencies": {        "credit_card": [          "billing_address"        ]      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["default"]

The schema defines a default value for the name property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "name": {          "type": "string",          "default": "N/A"        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["format"]

The schema defines a format property for the email property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "email": {          "type": "string",          "format": "email"        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["pattern"]

The schema defines a pattern for the phone_number property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "phone_number": {            "type": "string",            "pattern": "^(\([0-9]{3}\))?[0-9]{3}-[0-9]{4}$"        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["maxLength"]

The schema defines a maxLength for the name property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "name": {          "type": "string",          "maxLength": 10        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: `["minLength"]

The schema defines a minLength for the name property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "phone_number": {          "type": "string",          "minLength": 2        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["enum"]

The schema includes an enum property.

{  "data": {    "key": "product",    "schema": {      "properties": {        "day_of_week": {          "type": "string",          "enum": [            "Monday",            "Tuesday",            "Wednesday",            "Thursday",            "Friday"          ]        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["minimum"]

The schema defines a property that expects a minimum value of 0 when a legacy object record is created.

{  "data": {    "key": "product",    "schema": {      "properties": {        "order_count": {          "type": "number",          "minimum": 0        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["maximum"]

The schema defines an order_count property that expects a maximum value of 5 when a legacy object record is created.

{  "data": {    "key": "product",    "schema": {      "properties": {        "order_count": {          "type": "number",          "maximum": 5        }      }    }  }}

data.schema array must not contain duplicate elements

The schema defines a required field and that field contains the same property more than once.

{  "data": {    "key": "product",    "schema": {      "properties": {        "order_count": {          "type": "number"        },        "order_name": {          "type": "string"        }      },      "required": [ “order_count”, “order_count” ]    }  }}

data.schema Required properties not defined in schema:

The schema defines a required field and the required field contains a property name that has not been defined in the schema.

{  "data": {    "key": "product",    "schema": {      "properties": {        "order_count": {          "type": "number"        },        "order_name": {          "type": "string"        }      },      "required": [ “first_name” ]    }  }}

data.schema instance value ("object") not found in enum (possible values: ["boolean","integer","number","string","array"])

The schema defines a order_count property whose type is set to "object". Zendesk plans to deprecate nested objects. You can break these nested objects into separate legacy objects and link them using legacy relationships.

{  "data": {    "key": "product",    "schema": {      "properties": {        "order_count": {            "type": "object"        }      }    }  }}

data.schema An array type needs to requires the items property too

The schema defines an array but does not define a corresponding items property that specifies a type for the array items.

{  "data": {    "key": "product",    "schema": {      "properties": {          "type": "array"      }    }  }}

data.schema instance value ("object") not found in enum (possible values: ["boolean","integer","number","string"])

The schema defines an array and any of the items in the array are of type object. The only array item types supported are "boolean", "integer", "number", or "string".

{  "data": {    "key": "product",    "schema": {      "properties": {        "type": "array",        "items": {            "type": "object"        }      }    }  }}

data.schema instance value ([""]) not found in enum (possible values: ["boolean","integer","number","string","array"])

The schema defines a order_count property whose type is set to an array of "boolean". The type property of any property can only be one of the following strings: "boolean", "integer", "number", "string", or "array".

{  "data": {    "key": "product",    "schema": {      "properties": {        "order_count": {            "type": ["boolean"]        }      }    }  }}

data.schema object instance has properties which are not allowed by the schema: ["type", "title", "description", "properties"]

The schema of the legacy object type defines properties such as type, title, description, and properties at an incorrect level. Although these properties are supported, they need to be present at the correct level of nesting.

{  "data": {    "key": "product",    "schema": {      "properties": {        "type": "array",        "items": {          "title": "An Product Array",          "description": "A array of products",          "properties": {}        }      }    }  }}