mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[@types/hapi__joi] Add number type to ValidationErrorItem path property (#38036)
* Add number type to ValidationErrorItem.path * Formatting
This commit is contained in:
parent
d2e519565f
commit
2fa0eebeb7
@ -6,6 +6,7 @@ let x: any = null;
|
||||
declare const value: any;
|
||||
let num = 0;
|
||||
let str = '';
|
||||
let strOrNum: string | number;
|
||||
declare const bool: boolean;
|
||||
declare const exp: RegExp;
|
||||
declare const obj: object;
|
||||
@ -184,6 +185,14 @@ validErrItem = {
|
||||
context: obj
|
||||
};
|
||||
|
||||
validErrItem = {
|
||||
message: str,
|
||||
type: str,
|
||||
path: [str, num, str],
|
||||
options: validOpts,
|
||||
context: obj,
|
||||
};
|
||||
|
||||
validErrFunc = errs => errs;
|
||||
validErrFunc = errs => errs[0];
|
||||
validErrFunc = errs => 'Some error';
|
||||
@ -940,7 +949,7 @@ schema = Joi.lazy(() => schema, { once: true });
|
||||
Joi.validate(value, schema, validOpts, (err, value) => {
|
||||
x = value;
|
||||
str = err.message;
|
||||
str = err.details[0].path[0];
|
||||
strOrNum = err.details[0].path[0];
|
||||
str = err.details[0].message;
|
||||
str = err.details[0].type;
|
||||
});
|
||||
|
||||
11
types/hapi__joi/index.d.ts
vendored
11
types/hapi__joi/index.d.ts
vendored
@ -18,6 +18,7 @@
|
||||
// Alejandro Fernandez Haro <https://github.com/afharo>
|
||||
// Silas Rech <https://github.com/lenovouser>
|
||||
// Anand Chowdhary <https://github.com/AnandChowdhary>
|
||||
// Miro Yovchev <https://github.com/myovchev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@ -281,11 +282,11 @@ export interface ValidationError extends Error, JoiObject {
|
||||
}
|
||||
|
||||
export interface ValidationErrorItem {
|
||||
message: string;
|
||||
type: string;
|
||||
path: string[];
|
||||
options?: ValidationOptions;
|
||||
context?: Context;
|
||||
message: string;
|
||||
type: string;
|
||||
path: Array<string | number>;
|
||||
options?: ValidationOptions;
|
||||
context?: Context;
|
||||
}
|
||||
|
||||
export type ValidationErrorFunction = (errors: ValidationErrorItem[]) => string | ValidationErrorItem | ValidationErrorItem[] | Error;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user