When a function accepts an ordered mix of values, ordinary homogeneous-array validation is not enough. prefixItems assigns a separate schema to each positional element, turning an array into a tuple. section 12.1
Validate a catalog search call
A catalog search takes two arguments: catalog data first and a query string second. Its argument array can therefore use prefixItems to require the first position to match catalogSchema and the second to be a string. AJV can validate this array during development and testing, while production skips the repeated internal check. section 12.1
Listing 12.7 The schema for a tuple made of a string and a number
{
"type": "array",
"prefixItems": [
{ "type": "string" },
{ "type": "number" }
]
}
Compare the compact tuple schema: the first position accepts a string and the second accepts a number. section 12.1
