mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
updated to fully match 1.2.5
wrapped interfaces in a module, removed prefixes
This commit is contained in:
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for Tiny Validator tv4 1.0.6
|
||||
// Project: https://github.com/geraintluff/tv4
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface TV4ErrorCodes {
|
||||
[key:string]:number;
|
||||
}
|
||||
interface TV4Error {
|
||||
code:number;
|
||||
message:string;
|
||||
dataPath:string;
|
||||
schemaPath:string;
|
||||
}
|
||||
interface TV4SchemaMap {
|
||||
[uri:string]:any;
|
||||
}
|
||||
interface TV4BaseResult {
|
||||
missing:string[];
|
||||
valid:boolean;
|
||||
}
|
||||
interface TV4SingleResult extends TV4BaseResult {
|
||||
error:TV4Error;
|
||||
}
|
||||
interface TV4MultiResult extends TV4BaseResult {
|
||||
errors:TV4Error[];
|
||||
}
|
||||
interface TV4 {
|
||||
validateResult(data:any, schema:any):TV4SingleResult;
|
||||
validateMultiple(data:any, schema:any):TV4MultiResult;
|
||||
|
||||
addSchema(uri:string, schema:any):boolean;
|
||||
getSchema(uri:string):any;
|
||||
normSchema(schema:any, baseUri:string):any;
|
||||
resolveUrl(base:string, href:string):string;
|
||||
freshApi():TV4;
|
||||
dropSchemas():void;
|
||||
reset():void;
|
||||
|
||||
getMissingUris(exp?:RegExp):string[];
|
||||
getSchemaUris(exp?:RegExp):string[];
|
||||
getSchemaMap():TV4SchemaMap;
|
||||
errorCodes:TV4ErrorCodes;
|
||||
}
|
||||
declare module "tv4" {
|
||||
var tv4: TV4
|
||||
export = tv4;
|
||||
}
|
||||
Vendored
+95
-39
@@ -1,48 +1,104 @@
|
||||
// Type definitions for Tiny Validator tv4 1.0.6
|
||||
// Type definitions for Tiny Validator tv4 1.2.5
|
||||
// Project: https://github.com/geraintluff/tv4
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions by: Peter Snider <https://github.com/psnider>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface TV4ErrorCodes {
|
||||
[key:string]:number;
|
||||
}
|
||||
interface TV4Error {
|
||||
code:number;
|
||||
message:string;
|
||||
dataPath:string;
|
||||
schemaPath:string;
|
||||
}
|
||||
interface TV4SchemaMap {
|
||||
[uri:string]:any;
|
||||
}
|
||||
interface TV4BaseResult {
|
||||
missing:string[];
|
||||
valid:boolean;
|
||||
}
|
||||
interface TV4SingleResult extends TV4BaseResult {
|
||||
error:TV4Error;
|
||||
}
|
||||
interface TV4MultiResult extends TV4BaseResult {
|
||||
errors:TV4Error[];
|
||||
}
|
||||
interface TV4 {
|
||||
validateResult(data:any, schema:any):TV4SingleResult;
|
||||
validateMultiple(data:any, schema:any):TV4MultiResult;
|
||||
declare module tv4 {
|
||||
|
||||
// Note that every top-level property is optional in json-schema
|
||||
export interface JsonSchema {
|
||||
[key: string]: any;
|
||||
title?: string; // used for humans only, and not used for computation
|
||||
description?: string; // used for humans only, and not used for computation
|
||||
id?: string;
|
||||
$schema?: string;
|
||||
type?: string;
|
||||
items?: any;
|
||||
properties?: any;
|
||||
patternProperties?: any;
|
||||
additionalProperties?: boolean;
|
||||
required?: string[];
|
||||
definitions?: any;
|
||||
default?: any;
|
||||
}
|
||||
|
||||
addSchema(uri:string, schema:any):boolean;
|
||||
getSchema(uri:string):any;
|
||||
normSchema(schema:any, baseUri:string):any;
|
||||
resolveUrl(base:string, href:string):string;
|
||||
freshApi():TV4;
|
||||
dropSchemas():void;
|
||||
reset():void;
|
||||
export type SchemaMap = {[uri: string]: JsonSchema;};
|
||||
// maps error codes/names to human readable error description for a single language
|
||||
export type ErrorMap = {[errorCode: string]: string;};
|
||||
|
||||
getMissingUris(exp?:RegExp):string[];
|
||||
getSchemaUris(exp?:RegExp):string[];
|
||||
getSchemaMap():TV4SchemaMap;
|
||||
errorCodes:TV4ErrorCodes;
|
||||
|
||||
export interface ErrorCodes {
|
||||
[key:string]:number;
|
||||
}
|
||||
export interface ValidationError {
|
||||
code:number;
|
||||
message:any;
|
||||
dataPath?:string;
|
||||
schemaPath?:string;
|
||||
subErrors?: ValidationError[];
|
||||
}
|
||||
export interface ErrorVar extends ValidationError {
|
||||
params: any;
|
||||
subErrors: any;
|
||||
stack: string;
|
||||
}
|
||||
export interface BaseResult {
|
||||
missing:string[];
|
||||
valid:boolean;
|
||||
}
|
||||
export interface SingleResult extends BaseResult {
|
||||
error:ValidationError;
|
||||
}
|
||||
export interface MultiResult extends BaseResult {
|
||||
errors:ValidationError[];
|
||||
}
|
||||
export type FormatValidationFunction = (data: any, schema: JsonSchema) => string;
|
||||
// documentation doesnt agree with code in tv4, this type agrees with code
|
||||
export type KeywordValidationFunction = (data: any, value: any, schema: JsonSchema, dataPointerPath: string) => string | ValidationError;
|
||||
export type AsyncValidationCallback = (isValid: boolean, error: ValidationError) => void;
|
||||
export interface TV4 {
|
||||
error: ErrorVar;
|
||||
missing: string[];
|
||||
// primary API
|
||||
validate(data: any, schema: JsonSchema, checkRecursive?: boolean): boolean;
|
||||
validate(data: any, schema: JsonSchema, checkRecursive: boolean, banUnknownProperties: boolean): boolean;
|
||||
validateResult(data: any, schema: JsonSchema, checkRecursive?: boolean): SingleResult;
|
||||
validateResult(data: any, schema: JsonSchema, checkRecursive: boolean, banUnknownProperties: boolean): SingleResult;
|
||||
validateMultiple(data: any, schema: JsonSchema, checkRecursive?: boolean): MultiResult;
|
||||
validateMultiple(data: any, schema: JsonSchema, checkRecursive: boolean, banUnknownProperties: boolean): MultiResult;
|
||||
// from including: tv4.async-jquery.js
|
||||
validate(data: any, schema: JsonSchema, callback: AsyncValidationCallback, checkRecursive?: boolean): void;
|
||||
validate(data: any, schema: JsonSchema, callback: AsyncValidationCallback, checkRecursive: boolean, banUnknownProperties: boolean): void;
|
||||
|
||||
// additional API for more complex cases
|
||||
addSchema(schema: JsonSchema): void;
|
||||
addSchema(uri:string, schema: JsonSchema): void;
|
||||
getSchema(uri:string): JsonSchema;
|
||||
getSchemaMap(): SchemaMap;
|
||||
getSchemaUris(filter?: RegExp): string[];
|
||||
getMissingUris(filter?: RegExp): string[];
|
||||
dropSchemas(): void;
|
||||
freshApi(): TV4;
|
||||
reset(): void;
|
||||
setErrorReporter(lang: string): void;
|
||||
setErrorReporter(reporter: (error: ValidationError, data: any, schema: JsonSchema) => string): void;
|
||||
language(code: string): void;
|
||||
addLanguage(code: string, map: ErrorMap): void;
|
||||
addFormat(format: string, validationFunction: FormatValidationFunction): void;
|
||||
addFormat(formats: {[formatName: string]: FormatValidationFunction;}): void;
|
||||
defineKeyword(keyword: string, validationFunction: KeywordValidationFunction): void;
|
||||
defineError(codeName: string, codeNumber: number, defaultMessage: string): void;
|
||||
|
||||
// not documented
|
||||
normSchema(schema: JsonSchema, baseUri:string):any;
|
||||
resolveUrl(base:string, href:string):string;
|
||||
|
||||
errorCodes:ErrorCodes;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "tv4" {
|
||||
var tv4: TV4
|
||||
export = tv4;
|
||||
var out: tv4.TV4
|
||||
export = out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user