-
Notifications
You must be signed in to change notification settings - Fork 1.5k
node.get is not a function when validating #2156
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
Comments
I also see the error node.set is not a function with the following schema if this helps: const Joi = require("@hapi/joi");
const A = Joi.object()
.keys({
a: Joi.date().timestamp().raw().required(),
}).required()
.options({ stripUnknown: true });
const schema = Joi.alternatives(
Joi.array().items(A.required(), Joi.any().strip()),
A,
);
Joi.attempt([{a: new Date()}, {}, {a: 1}]) //ok
Joi.attempt([{a:1}]) // throws a proper error
Joi.attempt([{a:1, {}}]) // throws node.set is not a function The error for case 2 is:
error for case 3:
|
@hueniverse Is this something you're working on or should I take a stab at this? |
I have a fix, but I found another problem and I'd like to fix both at the same time. This is a simple bug. The other one is complicated. If I can't figure it out by tomorrow morning, I'll push a temporary fix. |
Alright. Let me know if I can help. |
Thanks @hueniverse and @BolajiOlajide! |
* 'master' of github.com:hapijs/joi: Update API.md Improve compile version conflict error message. Closes hapijs#2173 Closes hapijs#2172 Fix docs malformed code block ending at section `object.pattern.match` End code block Fix docs missing code block ending at section `date.less(date)` Fix function signature. Fixes hapijs#2170. Delete .npmrc Delete .editorconfig Delete feature_request.md Delete bug_report.md Delete CONTRIBUTING.md 16.1.7 Fix date format validation. Closes hapijs#2168 16.1.6 Closes hapijs#2165 16.1.5 Clarify error(). Closes hapijs#2158 Closes hapijs#2161 Fix handling of shadow values. Closes hapijs#2156
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Context
Validating an object against my schema throws
node.get
ornode.set
is not a function when I expect keys to be stripped instead.What are you trying to achieve or the steps to reproduce ?
I am trying to write a validation that strips out items that do not pass the set validation. See below for more details.
Create the following scenario
Which result you had ?
Error thrown for cases 1 and 3.
What did you expect ?
Expect the item to be stripped (if my usage is correct) otherwise an error from Joi explaining why the assertion failed.
The text was updated successfully, but these errors were encountered: