-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Can I warn on Unkown #2669
Comments
Still hoping to solve this problem. I'm happy to submit a PR that enables returning errors from |
|
Thanks, much appreciated. |
Hello @hueniverse ! I'm curious if you have any ideas for marking
This basically wraps any |
@j0sh77 Are you looking to turn an error into a warning globally? |
@hueniverse In a nutshell yes, for a given schema we want to turn all unknown key errors into warnings. The issue we're facing now when trying the solution you shared is that it works for the root level keys but not for nested object keys. I've tried using Joi link to achieve this but with no luck. |
Please open a new issue for recursive warning support and I'll try to get to it. |
Thank you! Filed #2739. |
Support plan
Context
How can we help?
We don't want to strip unknown object keys but we do want to throw a warning to user.
We're using
validateAsync
and must do so as we're usingexternal
.allowUnkown
disables errors, but doesn't let us catch unknown keys as warnings.An initial implementation caught errors and filtered the error type on
object.unknown
and warned based on that. However, because this was catching a thrown error fromJoi
that meant the rest of our code in thetry
block stopped running and we can't return the modified value that should be returned thus causing a bug I just found. This is still true even withabortEarly: false
.I need a way to either catch and filter errors before they throw or to make is so unknowns are allowed but return in the warning object. Is this possible?
The text was updated successfully, but these errors were encountered: