json-schema-library
Version:
Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation
18 lines (17 loc) • 750 B
TypeScript
import { JsonError } from "./types";
import { SchemaNode } from "./schemaNode";
/**
* Returns the json-schema of the given object property or array item.
* e.g. it steps by one key into the data
*
* This helper determines the location of the property within the schema (additional properties, oneOf, ...) and
* returns the correct schema.
*
* @param draft - validator
* @param key - property-name or array-index
* @param schema - json schema of current data
* @param data - parent of key
* @param [pointer] - pointer to schema and data (parent of key)
* @return Schema or Error if failed resolving key
*/
export default function step(node: SchemaNode, key: string | number, data?: any): SchemaNode | JsonError;