@types/joi
Advanced tools
Comparing version 9.0.32 to 9.0.33
@@ -43,2 +43,6 @@ // Type definitions for joi v9.0.0 | ||
context?: Object; | ||
/** | ||
* when true, do not apply default values. Defaults to false. | ||
*/ | ||
noDefaults?: boolean; | ||
} | ||
@@ -125,6 +129,6 @@ | ||
export interface ValidationError extends Error { | ||
message: string; | ||
isJoi: boolean; | ||
details: ValidationErrorItem[]; | ||
simple(): string; | ||
annotated(): string; | ||
annotate(): string; | ||
_object: any; | ||
} | ||
@@ -137,2 +141,3 @@ | ||
options?: ValidationOptions; | ||
context?: any; | ||
} | ||
@@ -293,2 +298,12 @@ | ||
empty(schema?: any): T; | ||
/** | ||
* Overrides the default joi error with a custom error if the rule fails where: | ||
* @param err - the override error. | ||
* | ||
* Note that the provided error will be returned as-is, unmodified and undecorated | ||
* with any of the normal joi error properties. If validation fails and another | ||
* error is found before the error override, that error will be returned and the | ||
* override will be ignored (unless the abortEarly option has been set to false). | ||
*/ | ||
error?(err: Error): T; | ||
} | ||
@@ -834,6 +849,14 @@ | ||
*/ | ||
export declare function validate<T>(value: T, schema: Schema, callback: (err: ValidationError, value: T) => void): void; | ||
export declare function validate<T>(value: T, schema: Object, callback: (err: ValidationError, value: T) => void): void; | ||
export declare function validate<T>(value: T, schema: Object, options?: ValidationOptions, callback?: (err: ValidationError, value: T) => void): ValidationResult<T>; | ||
export function validate<T>(value: T): ValidationResult<T>; | ||
export function validate<T, R>(value: T, callback: (err: ValidationError, value: T) => R): R; | ||
export function validate<T>(value: T, schema: Schema): ValidationResult<T>; | ||
export function validate<T>(value: T, schema: Object): ValidationResult<T>; | ||
export function validate<T, R>(value: T, schema: Schema, callback: (err: ValidationError, value: T) => R): R; | ||
export function validate<T, R>(value: T, schema: Object, callback: (err: ValidationError, value: T) => R): R; | ||
export function validate<T>(value: T, schema: Schema, options: ValidationOptions): ValidationResult<T>; | ||
export function validate<T>(value: T, schema: Object, options: ValidationOptions): ValidationResult<T>; | ||
export function validate<T, R>(value: T, schema: Schema, options: ValidationOptions, callback: (err: ValidationError, value: T) => R): R; | ||
export function validate<T, R>(value: T, schema: Object, options: ValidationOptions, callback: (err: ValidationError, value: T) => R): R; | ||
/** | ||
@@ -886,1 +909,116 @@ * Converts literal schema definition to joi schema object (or returns the same back if already a joi schema object). | ||
export function extend(extention: Extension): any; | ||
/** | ||
* Whitelists a value | ||
*/ | ||
export function allow(value: any, ...values: any[]): Schema; | ||
export function allow(values: any[]): Schema; | ||
/** | ||
* Adds the provided values into the allowed whitelist and marks them as the only valid values allowed. | ||
*/ | ||
export function valid(value: any, ...values: any[]): Schema; | ||
export function valid(values: any[]): Schema; | ||
export function only(value: any, ...values : any[]): Schema; | ||
export function only(values: any[]): Schema; | ||
export function equal(value: any, ...values : any[]): Schema; | ||
export function equal(values: any[]): Schema; | ||
/** | ||
* Blacklists a value | ||
*/ | ||
export function invalid(value: any, ...values: any[]): Schema; | ||
export function invalid(values: any[]): Schema; | ||
export function disallow(value: any, ...values : any[]): Schema; | ||
export function disallow(values: any[]): Schema; | ||
export function not(value: any, ...values : any[]): Schema; | ||
export function not(values: any[]): Schema; | ||
/** | ||
* Marks a key as required which will not allow undefined as value. All keys are optional by default. | ||
*/ | ||
export function required(): Schema; | ||
/** | ||
* Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default. | ||
*/ | ||
export function optional(): Schema; | ||
/** | ||
* Marks a key as forbidden which will not allow any value except undefined. Used to explicitly forbid keys. | ||
*/ | ||
export function forbidden(): Schema; | ||
/** | ||
* Marks a key to be removed from a resulting object or array after validation. Used to sanitize output. | ||
*/ | ||
export function strip(): Schema; | ||
/** | ||
* Annotates the key | ||
*/ | ||
export function description(desc: string): Schema; | ||
/** | ||
* Annotates the key | ||
*/ | ||
export function notes(notes: string): Schema; | ||
export function notes(notes: string[]): Schema; | ||
/** | ||
* Annotates the key | ||
*/ | ||
export function tags(notes: string): Schema; | ||
export function tags(notes: string[]): Schema; | ||
/** | ||
* Attaches metadata to the key. | ||
*/ | ||
export function meta(meta: Object): Schema; | ||
/** | ||
* Annotates the key with an example value, must be valid. | ||
*/ | ||
export function example(value: any): Schema; | ||
/** | ||
* Annotates the key with an unit name. | ||
*/ | ||
export function unit(name: string): Schema; | ||
/** | ||
* Overrides the global validate() options for the current key and any sub-key. | ||
*/ | ||
export function options(options: ValidationOptions): Schema; | ||
/** | ||
* Sets the options.convert options to false which prevent type casting for the current key and any child keys. | ||
*/ | ||
export function strict(isStrict?: boolean): Schema; | ||
/** | ||
* Returns a new type that is the result of adding the rules of one type to another. | ||
*/ | ||
export function concat<T>(schema: T): T; | ||
/** | ||
* Converts the type into an alternatives type where the conditions are merged into the type definition where: | ||
*/ | ||
export function when<U>(ref: string, options: WhenOptions<U>): AlternativesSchema; | ||
export function when<U>(ref: Reference, options: WhenOptions<U>): AlternativesSchema; | ||
/** | ||
* Overrides the key name in error messages. | ||
*/ | ||
export function label(name: string): Schema; | ||
/** | ||
* Outputs the original untouched value instead of the casted value. | ||
*/ | ||
export function raw(isRaw?: boolean): Schema; | ||
/** | ||
* Considers anything that matches the schema to be empty (undefined). | ||
* @param schema - any object or joi schema to match. An undefined schema unsets that rule. | ||
*/ | ||
export function empty(schema?: any) : Schema; |
{ | ||
"name": "@types/joi", | ||
"version": "9.0.32", | ||
"version": "9.0.33", | ||
"description": "TypeScript definitions for joi v9.0.0", | ||
@@ -14,4 +14,5 @@ "license": "MIT", | ||
"dependencies": {}, | ||
"peerDependencies": {}, | ||
"typings": "index.d.ts", | ||
"typesPublisherContentHash": "367a8e4cac231fb54f27015f36acbd9def3af52891752e9d2adea00be7867681" | ||
"typesPublisherContentHash": "931dd19abe8c948884c1d7d41feaa68d9c6ee7d1a73597dda2271bae02e4dff5" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Mon, 19 Sep 2016 17:28:59 GMT | ||
* Last updated: Mon, 14 Nov 2016 19:34:56 GMT | ||
* File structure: ProperModule | ||
@@ -14,0 +14,0 @@ * Library Dependencies: none |
@@ -6,4 +6,4 @@ { | ||
"moduleDependencies": [], | ||
"libraryMajorVersion": "9", | ||
"libraryMinorVersion": "0", | ||
"libraryMajorVersion": 9, | ||
"libraryMinorVersion": 0, | ||
"libraryName": "joi v9.0.0", | ||
@@ -23,3 +23,3 @@ "typingsPackageName": "joi", | ||
"hasPackageJson": false, | ||
"contentHash": "367a8e4cac231fb54f27015f36acbd9def3af52891752e9d2adea00be7867681" | ||
"contentHash": "931dd19abe8c948884c1d7d41feaa68d9c6ee7d1a73597dda2271bae02e4dff5" | ||
} |
36690
878