Skip to content

Commit

Permalink
Merge pull request hapijs#2829 from hekystyle/strict-details-param-of…
Browse files Browse the repository at this point in the history
…-validation-error-constructor

fix(d.ts)!: type details param of ValidationError constructor
  • Loading branch information
Marsup authored Sep 17, 2022
2 parents f855e9e + 25561fb commit f11bfe1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@ declare namespace Joi {
*/
version: string;

ValidationError: new (message: string, details: any, original: any) => ValidationError;
ValidationError: new (message: string, details: ValidationErrorItem[], original: any) => ValidationError;

/**
* Generates a schema object that matches any data type.
Expand Down
4 changes: 2 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ stringRegexOpts = { invert: bool };

// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---

const validErr = new Joi.ValidationError("message", "details", "original");
const validErr = new Joi.ValidationError("message", [], "original");
let validErrItem: Joi.ValidationErrorItem;
let validErrFunc: Joi.ValidationErrorFunction;

Expand Down Expand Up @@ -220,7 +220,7 @@ Joi.any().error(validErrFunc);

Joi.isError(validErr);

const maybeValidErr: any = new Joi.ValidationError("message", "details", "original");
const maybeValidErr: any = new Joi.ValidationError("message", [], "original");

if (Joi.isError(maybeValidErr)) {
// isError is a type guard that allows accessing these properties:
Expand Down

0 comments on commit f11bfe1

Please sign in to comment.