You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is this issue currently blocking your project? no:
is this issue affecting a production system? no:
Context
node version: 18.12.1
module version with issue: 17.8.3
last module version without issue: n/a
environment (e.g. node, browser, native): node
used with (e.g. hapi application, another framework, standalone, ...): standalone
any other relevant information: I'd be happy to contribute to a fix for this, just assign me. Thanks for everything!
What are you trying to achieve or the steps to reproduce?
In the type definition for validateAsync, when options include { warnings: true }, the return promise then includes a type of ValidationError[] for the warning. However, the actual value returned appears to be of type ValidationError (or is at least an object with message and details properties), regardless of how many warnings are returned (they are all included in the "details" ValidationErrorItem array, and the error message is a concatenated string of all the warning messages).
/** * Validates a value using the schema and options. */validateAsync<TOptsextendsAsyncValidationOptions>(value: any,options?: TOpts): Promise<TOptsextends{artifacts: true}|{warnings: true}
? {value: TSchema}&(TOptsextends{artifacts: true}
? {artifacts: Map<any,string[][]>}
: {})&(TOptsextends{warnings: true}
? {warning: ValidationError[]}// actual return is ValidationError
: {})
: TSchema>;
What was the result you got?
I got a type error when trying to access and iterate over the details property of the resolved value for warning from validateAsync({ warnings: true }).
What result did you expect?
No type errors and a type definition that aligns with the return value
The text was updated successfully, but these errors were encountered:
Thanks for the report and for offering your help, I felt it would be easier if I made the fix. It's not exactly a ValidationError as it doesn't inherit from Error, but it shares most of its properties indeed.
Support plan
Context
What are you trying to achieve or the steps to reproduce?
In the type definition for validateAsync, when options include
{ warnings: true }
, the return promise then includes a type ofValidationError[]
for the warning. However, the actual value returned appears to be of type ValidationError (or is at least an object with message and details properties), regardless of how many warnings are returned (they are all included in the "details"ValidationErrorItem
array, and the error message is a concatenated string of all the warning messages).To reproduce, run the following code with Node:
The logged result will be the following, which is an object where the expected type is an array:
Here is the type definition for validateAsync:
What was the result you got?
I got a type error when trying to access and iterate over the details property of the resolved value for
warning
fromvalidateAsync({ warnings: true })
.What result did you expect?
No type errors and a type definition that aligns with the return value
The text was updated successfully, but these errors were encountered: