joi
joi copied to clipboard
Missing Return Type ErrorReport[] for any.error ValidationErrorFunction
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
It seems that the type definition for return type of any.error which is a function of type ValidationErrorFunction does not have the proper return signature. As per documentation:
The ValidationErrorFunction should return either a single Error or an array of validation reports but it seems like it does not. I have added ErrorReport[] as another of the possible return types. This should probably be fixed if this issue is legitimate.
Here is the diff that solved my problem:
diff --git a/node_modules/joi/lib/index.d.ts b/node_modules/joi/lib/index.d.ts
index d6218c6..350a8c9 100644
--- a/node_modules/joi/lib/index.d.ts
+++ b/node_modules/joi/lib/index.d.ts
@@ -659,7 +659,7 @@ declare namespace Joi {
context?: Context;
}
- type ValidationErrorFunction = (errors: ErrorReport[]) => string | ValidationErrorItem | Error;
+ type ValidationErrorFunction = (errors: ErrorReport[]) => string | ValidationErrorItem | Error | ErrorReport[];
type ValidationResult<TSchema = any> = {
error: undefined;
This issue body was partially generated by patch-package.