UNPKG

@squiz/json-schema-library

Version:

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation

21 lines (19 loc) 572 B
import { JSONSchema, JSONPointer } from "./types"; import { Draft as Core } from "./draft"; /** * Test if the data is valid according to the given schema * * @param core - validator * @param value - value to validate * @param [schema] - json schema * @param [pointer] - json pointer pointing to value * @return if schema does match given value */ export default function isValid( core: Core, value: any, schema: JSONSchema = core.rootSchema, pointer: JSONPointer = "#" ): boolean { return core.validate(value, schema, pointer).length === 0; }