UNPKG

jaywalk

Version:
35 lines (34 loc) 1.83 kB
import Promise = require('any-promise'); import { ValidationError } from './support/error'; import { Rule } from './types/rule'; export declare function ref($ref: string[], $offset?: number): { $ref: string[]; $offset: number; }; export interface Ref { $ref: string[]; $offset?: number; } export declare function toValue(value: void | string | number | boolean | Ref): (path: string[], context: any) => any; export declare function getValue(value: any, path: string[]): any; export declare function relativePath(ctx: string[], ref: string[], offset?: number): string[]; export interface Context { root: any; error: (path: string[], type: string, keyword: string, assertion: any, value: any) => ValidationError; rootSchema: Rule; } export declare function identity<T>(value: T): T; export declare function toNext<T>(value: T, path: string[], context: Context, next: (value: T) => T): T; export declare type NextFunction<T> = (value: T) => Promise<T>; export interface TestFn<T> { (value: T, path: string[], context: Context, next: NextFunction<T>): T | Promise<T>; } export interface CompiledFn<T> { (value: T, path: string[], context: Context, next: NextFunction<T>): Promise<T>; } export declare function compose(tests: Array<TestFn<any>>): CompiledFn<any>; export declare function formatPath(segments: string[]): string; export declare function wrapIsType<T>(_this: any, value: any, path: string[], context: Context, _test: (value: any, path: string[], context: Context) => number, test: (value: any, path: string[], context: Context) => number): number; export declare function extendSchema<T extends Rule>(schema: T, options: any): T; export declare function merge(...values: any[]): any; export declare function isType(schema: Rule, value: any, path: string[], context: Context): number;