Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Known issue in v6: Uncomfortable error info of Union validation #216

Open
yuhr opened this issue Apr 4, 2021 · 1 comment
Open

Known issue in v6: Uncomfortable error info of Union validation #216

yuhr opened this issue Apr 4, 2021 · 1 comment
Labels

Comments

@yuhr
Copy link
Collaborator

yuhr commented Apr 4, 2021

As for error reporting, current implementation of Union is somewhat incomplete, for example:

console.log(Union(String, Number, Record({ test: Boolean })).validate({ test: new Date() }));

Then we get:

{
    success: false,
    code: 'TYPE_INCORRECT',
    message: 'Expected string | number | { test: boolean; }, but was object'
}

This is not very helpful. Error reporting algorithm of Union (and also maybe Intersect) seems non-trivial, so I need to investigate how this can be resolved. This issue should be considered as a bug, because above result is just unintentional and incorrect, and we're going to treat bugfixes for this as non-breaking changes.

@abakimatov
Copy link

Hello, is there any news about this problem? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants