@types/joi
Advanced tools
Comparing version 10.3.2 to 10.4.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for joi v10.3.0 | ||
// Type definitions for joi v10.4.0 | ||
// Project: https://github.com/hapijs/joi | ||
@@ -149,5 +149,12 @@ // Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Laurence Dougal Myers <https://github.com/laurence-myers>, Christopher Glantschnig <https://github.com/cglantschnig>, David Broder-Rodgers <https://github.com/DavidBR-SW>, Gael Magnan de Bornier <https://github.com/GaelMagnan>, Rytis Alekna <https://github.com/ralekna>, Pavel Ivanov <https://github.com/schfkt> | ||
options?: ValidationOptions; | ||
context?: any; | ||
context?: { | ||
[key: string]: any; | ||
value?: any; | ||
}; | ||
} | ||
export interface ValidationErrorFunction { | ||
(errors: ValidationErrorItem[]): string | ValidationErrorItem | ValidationErrorItem[] | Error; | ||
} | ||
export interface ValidationResult<T> { | ||
@@ -317,10 +324,19 @@ error: ValidationError; | ||
* Overrides the default joi error with a custom error if the rule fails where: | ||
* @param err - the override error. | ||
* @param err - can be: | ||
* an instance of `Error` - the override error. | ||
* a `function(errors)`, taking an array of errors as argument, where it must either: | ||
* return a `string` - substitutes the error message with this text | ||
* return a single `object` or an `Array` of it, where: | ||
* `type` - optional parameter providing the type of the error (eg. `number.min`). | ||
* `message` - optional parameter if `template` is provided, containing the text of the error. | ||
* `template` - optional parameter if `message` is provided, containing a template string, using the same format as usual joi language errors. | ||
* `context` - optional parameter, to provide context to your error if you are using the `template`. | ||
* return an `Error` - same as when you directly provide an `Error`, but you can customize the error message based on the errors. | ||
* | ||
* 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). | ||
* Note that if you provide an `Error`, it 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; | ||
error?(err: Error | ValidationErrorFunction): T; | ||
} | ||
@@ -327,0 +343,0 @@ |
{ | ||
"name": "@types/joi", | ||
"version": "10.3.2", | ||
"version": "10.4.0", | ||
"description": "TypeScript definitions for joi", | ||
@@ -44,4 +44,4 @@ "license": "MIT", | ||
"peerDependencies": {}, | ||
"typesPublisherContentHash": "6619024f4c504ec8c16edfa7fbcdadb1732fefb25297c75cf676ddef9db192b9", | ||
"typesPublisherContentHash": "e54a197b81f2c73405e66034cafbe4f45035cb00f3a1cfc3ba8702123de88e69", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Wed, 03 May 2017 18:57:19 GMT | ||
* Last updated: Fri, 02 Jun 2017 01:33:57 GMT | ||
* Dependencies: none | ||
@@ -14,0 +14,0 @@ * Global values: none |
41029
911