We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d6355d3 commit 6b34f10Copy full SHA for 6b34f10
spec.lua
@@ -122,10 +122,11 @@ end
122
---@return fun(value: any): boolean
123
function M.optional(spec)
124
return function(value)
125
- if value then
126
- return spec(value)
+ -- if no value is specified return true!
+ if value == nil then
127
+ return true
128
end
- return true
129
+ return spec(value)
130
131
132
spec_test.lua
@@ -47,6 +47,7 @@ describe("spec.lua", function()
47
assert.True(spec.optional(spec.string) "Hello, World")
48
assert.True(spec.optional(spec.string)(nil))
49
assert.False(spec.optional(spec.string)(true))
50
+ assert.False(spec.optional(spec.string)(false))
51
end)
52
53
it("spec.all_of", function()
0 commit comments