feat(vim.validate): improve fast form and deprecate spec form

Problem:

`vim.validate()` takes two forms when it only needs one.

Solution:

- Teach the fast form all the features of the spec form.
- Deprecate the spec form.
- General optimizations for both forms.
- Add a `message` argument which can be used alongside or in place
  of the `optional` argument.
This commit is contained in:
Lewis Russell
2024-10-18 11:33:12 +01:00
committed by Lewis Russell
parent 6fd13eedda
commit 3572319b4c
20 changed files with 355 additions and 374 deletions

View File

@@ -229,7 +229,7 @@ end
---@return (string[]) # Normalized paths |vim.fs.normalize()| of all matching items
function M.find(names, opts)
opts = opts or {}
vim.validate({ names = { names, { 'string', 'table', 'function' } } })
vim.validate('names', names, { 'string', 'table', 'function' })
vim.validate('path', opts.path, 'string', true)
vim.validate('upward', opts.upward, 'boolean', true)
vim.validate('stop', opts.stop, 'string', true)