We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
node.js
17.x
No response
standalone
I was able to reproduce this issue at https://joi.dev/tester/.
When chaining multiple calls to empty(), only the last call is considered. Here's a simple example:
empty()
// Schema Joi.object({ testA: Joi.string().empty("a").empty("b"), testB: Joi.string().empty("a").empty("b") } // Data { testA: "a", testB: "b" } // Expected result {} // Actual result { testA: "a" }
The workaround is to pass an array to .empty(), which works as expected for all values.
.empty()
// Schema Joi.object({ testA: Joi.string().empty(["a", "b"]), testB: Joi.string().empty(["a", "b"]) }) // Data { testA: "a", testB: "b" } // Result {}
Only the last call to .empty() is honored.
I expect calls to .empty() to "stack" like other methods. For example, this works fine:
// Schema Joi.object({ test1: Joi.string().allow(1).allow(2), test2: Joi.string().allow(1).allow(2) }) // Data { test1: 1, test2: 2 } // Result { test1: 1, test2: 2 }
The text was updated successfully, but these errors were encountered:
What I've reported as "unexpected" might be the intended behavior based on this test in test/base.js#1227:
test/base.js#1227
describe('empty()') it('should override any previous empty')
If that's the case, I think an update to the documentation is needed.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Runtime
node.js
Runtime version
17.x
Module version
Last module version without issue
No response
Used with
standalone
Any other relevant information
I was able to reproduce this issue at https://joi.dev/tester/.
What are you trying to achieve or the steps to reproduce?
When chaining multiple calls to
empty()
, only the last call is considered. Here's a simple example:The workaround is to pass an array to
.empty()
, which works as expected for all values.What was the result you got?
Only the last call to
.empty()
is honored.What result did you expect?
I expect calls to
.empty()
to "stack" like other methods. For example, this works fine:The text was updated successfully, but these errors were encountered: