UNPKG

@jkcfg/std

Version:

jk standard library

34 lines (33 loc) 1.13 kB
/** * @module std/schema */ import { ValidationResult } from './validation'; /** * validateWithObject validates a value using a JSON schema supplied * as object. * * ```typescript * const result = validateWithObject(5, { type: 'number' }); * ``` */ export declare function validateWithObject(obj: any, schema: Record<string, any>): ValidationResult; /** * validateWithFile validates a value using a schema located at * the path (relative to the input directory). */ export declare function validateWithFile(obj: any, path: string): Promise<ValidationResult>; /** * validateWithResource validates a value using a schema location at * the given path relative to the module represented by `moduleRef`; * this is intended to be used by wrapping it in * `@jkcfg/std/resource#withModuleRef`. * * ```javascript * import { withModuleRef } from '@jkcfg/std/resource'; * * export function validate(value) { * return withModuleRef(ref => validateWithSchema(value, 'schema.json', ref)); * } * ``` */ export declare function validateWithResource(obj: any, path: string, moduleRef: string): Promise<ValidationResult>;