-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Skmatc TypeScript definition
- Loading branch information
1 parent
7021652
commit ff4e8c1
Showing
6 changed files
with
48 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,65 @@ | ||
declare module "skmatc" { | ||
export = Skmatc; | ||
export = Skmatc.Skmatc; | ||
} | ||
|
||
declare class Skmatc { | ||
constructor(schema: any); | ||
|
||
static validators: [SkmatcCore.IValidator]; | ||
static Validator: SkmatcCore.IValidatorStatic; | ||
static Result: SkmatcCore.IResultStatic; | ||
static Failure: SkmatcCore.IFailureStatic; | ||
static create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => SkmatcCore.IResult, options?: any): SkmatcCore.IValidator; | ||
static validate(validators: [SkmatcCore.IValidator], schema: any, data: any, path?: string): SkmatcCore.IResult; | ||
static register(validator: SkmatcCore.IValidator); | ||
|
||
schema: any; | ||
validators: [SkmatcCore.IValidator]; | ||
validate(data: any, path?: string): SkmatcCore.IResult; | ||
register(validator: SkmatcCore.IValidator); | ||
} | ||
|
||
declare module SkmatcCore { | ||
interface IValidatorStatic { | ||
(skmatc: Skmatc, options?: any): IValidator; | ||
create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => IResult, options?: any): IValidator; | ||
module(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => IResult, options?: any): IValidator; | ||
declare module Skmatc { | ||
export class Skmatc { | ||
constructor(schema: any); | ||
|
||
static validators: [Validator]; | ||
static Validator: typeof Validator; | ||
static Result: typeof Result; | ||
static Failure: typeof Failure; | ||
static create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: any): Validator; | ||
static validate(validators: [Validator], schema: any, data: any, path?: string): Result; | ||
static register(validator: Validator); | ||
|
||
schema: any; | ||
validators: [Validator]; | ||
validate(data: any, path?: string): Result; | ||
register(validator: Validator); | ||
} | ||
|
||
export class Validator { | ||
constructor(skmatc: Skmatc, options?: any); | ||
static create(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: any): Validator; | ||
static module(handles: (schema: any) => boolean, validate: (schema: any, data: any, path: string) => Result, options?: any): Validator; | ||
|
||
interface IValidator { | ||
name: string; | ||
skmatc: Skmatc; | ||
handles(schema: any): boolean; | ||
validate(schema: any, data: any, path: string): IResult; | ||
assert(schema: any, data: any, path: string, test: boolean, message?: string): IResult; | ||
fail(schema: any, data: any, path: string, message?: string): IResult; | ||
validate(schema: any, data: any, path: string): Result; | ||
assert(schema: any, data: any, path: string, test: boolean, message?: string): Result; | ||
fail(schema: any, data: any, path: string, message?: string): Result; | ||
} | ||
|
||
interface IResultStatic { | ||
(failures: [IFailure]): IResult; | ||
compound(results: [IResult]): IResult; | ||
} | ||
|
||
interface IResult { | ||
failures: [IFailure]; | ||
|
||
export class Result { | ||
constructor(failures: [Failure]); | ||
static compound(results: [Result]): Result; | ||
|
||
failures: [Failure]; | ||
success: boolean; | ||
failed: boolean; | ||
message: string; | ||
messages: [string]; | ||
error: Error; | ||
} | ||
|
||
interface IFailureStatic { | ||
(validator: IValidator, schema: any, data: any, path: string, message?: string): IFailure; | ||
} | ||
|
||
interface IFailure { | ||
validator: IValidator; | ||
|
||
export class Failure { | ||
constructor(validator: Validator, schema: any, data: any, path: string, message?: string); | ||
validator: Validator; | ||
schema: any; | ||
data: any; | ||
path: string; | ||
message: string; | ||
} | ||
|
||
interface IValidationHandler { | ||
export interface IValidationHandler { | ||
(thisArg: { | ||
validator: IValidationHandler; | ||
skmatc: Skmatc; | ||
fail(message?: string); | ||
assert(test: boolean, message?: string); | ||
}, schema: any, data: any, path: string): IResult; | ||
}, schema: any, data: any, path: string): Result; | ||
} | ||
} |