@fibjs/enforce
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -1,4 +0,4 @@ | ||
declare namespace enforce { | ||
declare namespace FibjsEnforce { | ||
interface enforcementValidation { | ||
(...args: any[]): enforce.IValidator | ||
(...args: any[]): FibjsEnforce.IValidator | ||
} | ||
@@ -16,5 +16,4 @@ | ||
context(name: string, value: any): IEnforce; | ||
clear(); | ||
check(data: any, cb: (error: Error) => void); | ||
check(data: any, cb: (errors: Error[]) => void); | ||
clear(): void; | ||
check(data: any, cb: (error: Error | Error[]) => void): any; | ||
} | ||
@@ -34,10 +33,10 @@ | ||
ifDefined(): enforce.IValidator | ||
ifNotEmptyString(): enforce.IValidator | ||
ifType(type: string): enforce.IValidator | ||
ifNotType(type: string): enforce.IValidator | ||
ifDefined(): FibjsEnforce.IValidator | ||
ifNotEmptyString(): FibjsEnforce.IValidator | ||
ifType(type: string): FibjsEnforce.IValidator | ||
ifNotType(type: string): FibjsEnforce.IValidator | ||
} | ||
export interface ValidationCallback { | ||
(value: any, next: (errorMessage?: string) => boolean, contexts: ContextMap); | ||
(value: any, next: (errorMessage?: string) => boolean, thisArg?: any, contexts?: ContextMap): void; | ||
} | ||
@@ -56,19 +55,22 @@ | ||
export const Enforce: { new (options?: Options): IEnforce; } | ||
export const Validator: { new (callback: ValidationCallback): IValidator; } | ||
interface ExportModule { | ||
Enforce: { new (options?: Options): IEnforce; } | ||
Validator: { new (callback: ValidationCallback): IValidator; } | ||
export const lists: enforcementsContainer; | ||
export const ranges: enforcementsContainer; | ||
export const security: enforcementsContainer; | ||
export const patterns: enforcementsContainer; | ||
lists: enforcementsContainer; | ||
ranges: enforcementsContainer; | ||
security: enforcementsContainer; | ||
patterns: enforcementsContainer; | ||
/* common :start */ | ||
export const required: enforcementValidation; | ||
export const notEmptyString: enforcementValidation; | ||
export const sameAs: enforcementValidation; | ||
/* common :end */ | ||
/* common :start */ | ||
required: enforcementValidation; | ||
notEmptyString: enforcementValidation; | ||
sameAs: enforcementValidation; | ||
/* common :end */ | ||
} | ||
} | ||
declare module "@fibjs/enforce" { | ||
export = enforce | ||
const mod: FibjsEnforce.ExportModule | ||
export = mod | ||
} |
v0.0.7 / 2018-11-11 | ||
v0.0.8 / 2019-03-06 | ||
================== | ||
* upgrade dependencies, typo fix. | ||
v0.0.7 / 2018-11-11 | ||
=================== | ||
* Release v0.0.7 | ||
* typo fix | ||
@@ -6,0 +12,0 @@ |
@@ -16,3 +16,3 @@ /// <reference path="../@types/index.d.ts" /> | ||
if (validator.validate === undefined) { | ||
throw new Error('Missing validator (function) in Enforce.add(property, validator)'); | ||
throw new Error('Missing validator (function) in FibjsEnforce.add(property, validator)'); | ||
} | ||
@@ -19,0 +19,0 @@ if (!this.validations.hasOwnProperty(property)) |
@@ -7,3 +7,4 @@ /// <reference path="../@types/index.d.ts" /> | ||
} | ||
validate(data, next, thisArg, contexts = {}) { | ||
validate(data, next, thisArg, contexts) { | ||
contexts = contexts || {}; | ||
this.validator.apply(thisArg, [data, next, contexts]); | ||
@@ -10,0 +11,0 @@ } |
{ | ||
"name": "@fibjs/enforce", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "", | ||
@@ -15,3 +15,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"build": "fib-typify src -o lib -c .typify.json", | ||
"build": "fib-typify src -o lib", | ||
"test": "fibjs test/run.js", | ||
@@ -23,4 +23,4 @@ "ci": "npm run build && npm run test", | ||
"@fibjs/ci": "^2.1.0", | ||
"@types/fibjs": "^0.26.0", | ||
"fib-typify": "^0.3.0" | ||
"@types/fibjs": "^0.26.5", | ||
"fib-typify": "^0.5.2" | ||
}, | ||
@@ -27,0 +27,0 @@ "ci": { |
108929
1600