Skip to content

Commit a7f0cb6

Browse files
committed
test: validate delimiter options
1 parent f9dc8e2 commit a7f0cb6

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

lua/ninjection/health.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,34 @@ function M.validate_config(cfg)
248248
local is_valid = true
249249
local errors = {}
250250

251+
---@type table<string, NJDelimiterPair>|nil
252+
local format_delimiters = cfg.format_delimiters
253+
if not format_delimiters then
254+
is_valid = false
255+
table.insert(errors,"`format_delimiters` must be configured.")
256+
else
257+
if type(format_delimiters) == "table" then
258+
for k, v in pairs(format_delimiters) do
259+
---@type unknown
260+
local val = v
261+
if type(val) ~= "table" then
262+
table.insert(errors, "`format_delimiters[" .. k .. "]` must be a table")
263+
is_valid = false
264+
else
265+
---@type string|unknown
266+
local start_delim = val["start"]
267+
---@type string|unknown
268+
local end_delim = val["end"]
269+
270+
if type(start_delim) ~= "string" or type(end_delim) ~= "string" then
271+
table.insert(errors, "`format_delimiters[" .. k .. "]` must have string 'start' and 'end' keys.")
272+
is_valid = false
273+
end
274+
end
275+
end
276+
end
277+
end
278+
251279
---@type table<boolean>
252280
local valid_editor_styles = { cur_win = true, floating = true, v_split = true, h_split = true }
253281
if not valid_editor_styles[cfg.editor_style] then

0 commit comments

Comments
 (0)