-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Joi wrong value parsing #964
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
Works for me without all your models things you didn't provide, you'll have to give me something I can reproduce. |
@Marsup just changed the value of |
@akaNightmare In your validated body try changing: value: '{}' to value: {} |
It'll indeed fix it but that's still a bug. I don't have time to work on it right now. |
@Marsup I didn't realize Joi.object() is supposed to validate against stringified json/javascript? |
Here is a simple case that reproduces the bug: const Joi = require("joi");
const schema = Joi.object({
key: Joi.object({
allowedKey: Joi.string()
})
});
Joi.attempt({key: `{"forbiddenKey":"value"}`}, schema);
// TypeError: Cannot assign to read only property
// '_$miss$_forbiddenKey|1_$end$_' of {"forbiddenKey":"value"} This example on RunKit: I hope it helps to fix it! |
Context
Which result you had ?
Cannot create property '$miss$default|1$end$' on string '{}'
What did you expect ?
The text was updated successfully, but these errors were encountered: