scripts: check_site: add need_number_range check
This commit is contained in:
parent
6a371d88f0
commit
b181803ac4
@ -32,6 +32,7 @@ files["package/**/check_site.lua"] = {
|
|||||||
"need_chanlist",
|
"need_chanlist",
|
||||||
"need_domain_name",
|
"need_domain_name",
|
||||||
"need_number",
|
"need_number",
|
||||||
|
"need_number_range",
|
||||||
"need_one_of",
|
"need_one_of",
|
||||||
"need_string",
|
"need_string",
|
||||||
"need_string_array",
|
"need_string_array",
|
||||||
|
@ -289,6 +289,19 @@ function M.need_number(path, required)
|
|||||||
return need_type(path, 'number', required, 'be a number')
|
return need_type(path, 'number', required, 'be a number')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.need_number_range(path, min, max, required)
|
||||||
|
local val = need_type(path, 'number', required)
|
||||||
|
if not val then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if val < min or val > max then
|
||||||
|
var_error(path, val, "be in range [" .. min .. ", " .. max .. "]")
|
||||||
|
end
|
||||||
|
|
||||||
|
return val
|
||||||
|
end
|
||||||
|
|
||||||
function M.need_boolean(path, required)
|
function M.need_boolean(path, required)
|
||||||
return need_type(path, 'boolean', required, 'be a boolean')
|
return need_type(path, 'boolean', required, 'be a boolean')
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user