fix(lua): vim.validate message param #33675

Problem:
vim.validate does not handle `message` param.

Solution:
Add the missing logic.

(cherry picked from commit 40351bbbbe)
This commit is contained in:
Justin M. Keyes
2025-05-04 16:36:32 -07:00
committed by github-actions[bot]
parent c753e70abb
commit dc87a0d80a
4 changed files with 28 additions and 15 deletions

View File

@@ -1528,11 +1528,16 @@ describe('lua stdlib', function()
pcall_err(exec_lua, "vim.validate('arg1', nil, {'number', 'string'})")
)
-- Pass an additional message back.
-- Validator func can return an extra "Info" message.
matches(
'arg1: expected %?, got 3. Info: TEST_MSG',
pcall_err(exec_lua, "vim.validate('arg1', 3, function(a) return a == 1, 'TEST_MSG' end)")
)
-- Caller can override the "expected" message.
eq(
'arg1: expected TEST_MSG, got nil',
pcall_err(exec_lua, "vim.validate('arg1', nil, 'table', 'TEST_MSG')")
)
end)
it('vim.validate (spec form)', function()