Skip to content

Warning on rejected async validation #3100

@armpogart

Description

@armpogart

Runtime

node.js

Runtime version

18+

Module version

17.13.3

Last module version without issue

No response

Used with

standalone

Any other relevant information

No response

What are you trying to achieve or the steps to reproduce?

Currently synchronous validation returns ValidationResult<TSchema> type, which is following:

type ValidationResult<TSchema = any> = {
        error: undefined;
        warning?: ValidationError;
        value: TSchema;
    } | {
        error: ValidationError;
        warning?: ValidationError;
        value: any;
    }

So both in case of successful validation and error we always have warnings in the result. But when switching to asynchronous validation with warnings turned on validateAsync(value, { warnings: true }) in case of error the promise rejects and we have only ValidationError which doesn't incllude any warnings.

If this is by design, and synchronous and asynchronous validation have that difference, then it's not documented anywhere clearly.

Is there any way to still have the warnings in case of promise rejection for async validation?

What was the result you got?

error on promise rejection

What result did you expect?

error with warnings included

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug or defect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions