Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lua/reactive/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,29 @@ end

---@param preset Reactive.Preset
function M:add_preset(preset)
vim.validate {
name = {
preset.name,
function(value)
if type(value) ~= 'string' then
return false, 'preset name has to be a string'
end
local validator = function(value)
if type(value) ~= 'string' then
return false, 'preset name has to be a string'
end

local invalid_chars = value:match '[^a-zA-Z0-9_-]+'
local invalid_chars = value:match '[^a-zA-Z0-9_-]+'

if invalid_chars ~= nil then
return false,
[[You've used an invalid character(s) in a preset name.
if invalid_chars ~= nil then
return false,
[[You've used an invalid character(s) in a preset name.
Allowed: a-z A-Z 0-9 _ -
Whitespace is not allowed as well.
Your invalid characters:]] .. invalid_chars
end
end

return true
end,
'a valid string',
},
}
return true
end

if vim.fn.has 'nvim-0.11' == 1 then
vim.validate('name', preset.name, validator, 'a valid string')
else
vim.validate { name = { preset.name, validator, 'a valid string' } }
end

preset = Preset:parse(preset)

Expand Down