UNPKG

object-shape-tester

Version:
20 lines (19 loc) 868 B
import { type PartialWithUndefined } from '@augment-vir/common'; import { type ShapeDefinition } from './define-shape/shape-specifiers.js'; import { type CheckShapeValidityOptions } from './verify-shape/verify-shape.js'; /** * Parse a JSON string and verify it against the given shape definition. * * @category Main * @example * * ```ts * import {parseJsonWithShape, defineShape} from 'object-shape-tester'; * * const result = parseJsonWithShape('{"a": "hello"}', defineShape({a: ''})); * ``` * * @throws If the parsed JSON does not match the shape definition or if the JSON parsing throws an * error. */ export declare function parseJsonWithShape<const Shape extends ShapeDefinition<any, any>>(json: string, shape: Readonly<Shape>, options?: PartialWithUndefined<CheckShapeValidityOptions>, failureMessage?: string | undefined): Shape['runtimeType'];