local table = require "table"
local string = require "string"
local require, pcall, ipairs, pairs = require, pcall, ipairs, pairs
local type, error, tonumber, tostring = type, error, tonumber, tostring
local table = require "table"
local string = require "string"
local require, pcall, ipairs, pairs = require, pcall, ipairs, pairs
local type, error, tonumber, tostring = type, error, tonumber, tostring
-local unpack, loadfile = unpack, loadfile
+local unpack, loadfile, collectgarbage = unpack, loadfile, collectgarbage
local datatypes = require "luci.uvl.datatypes"
local validation = require "luci.uvl.validation"
local dependencies = require "luci.uvl.dependencies"
local datatypes = require "luci.uvl.datatypes"
local validation = require "luci.uvl.validation"
local dependencies = require "luci.uvl.dependencies"
--- Boolean; default true;
-- treat sections found in config but not in scheme as error
STRICT_UNKNOWN_SECTIONS = true
--- Boolean; default true;
-- treat sections found in config but not in scheme as error
STRICT_UNKNOWN_SECTIONS = true
for k, v in pairs(co:config()) do
local so = co:section(k)
if not self.beenthere[so:cid()] then
for k, v in pairs(co:config()) do
local so = co:section(k)
if not self.beenthere[so:cid()] then
for _, k in ipairs(util.keys(sc)) do
local so = co:section(k)
if so:scheme('required') and sc[k] == 0 then
for _, k in ipairs(util.keys(sc)) do
local so = co:section(k)
if so:scheme('required') and sc[k] == 0 then
end
for _, v in ipairs(section:variables()) do
local ok, err = self:_validate_option( v )
if not ok and (
v:scheme('required') or v:scheme('type') == "enum" or (
end
for _, v in ipairs(section:variables()) do
local ok, err = self:_validate_option( v )
if not ok and (
v:scheme('required') or v:scheme('type') == "enum" or (
end
if STRICT_UNKNOWN_OPTIONS and not section:scheme('dynamic') then
for k, v in pairs(section:config()) do
local oo = section:option(k)
end
if STRICT_UNKNOWN_OPTIONS and not section:scheme('dynamic') then
for k, v in pairs(section:config()) do
local oo = section:option(k)
- if k:sub(1,1) ~= "." and not self.beenthere[oo:cid()] then
- section:error(ERR.OPT_UNKNOWN(oo))
+ if k:byte(1) == 46 and not self.beenthere[oo:cid()] then
+ section:error(ERR('OPT_UNKNOWN', oo))
local config_values = ( type(val) == "table" and val or { val } )
for _, v in ipairs(config_values) do
if not scheme_values[v] then
local config_values = ( type(val) == "table" and val or { val } )
for _, v in ipairs(config_values) do
if not scheme_values[v] then
for i, v in ipairs(val) do
if not self.datatypes[dt]( v ) then
return false, option:error(
for i, v in ipairs(val) do
if not self.datatypes[dt]( v ) then
return false, option:error(
- return false, option:error(ERR.OPT_DATATYPE(option, dt))
+ return false, option:error(ERR('OPT_DATATYPE', option, dt))
for _, v in ipairs(val) do
if option:scheme('minlength') then
if #v < option:scheme('minlength') then
for _, v in ipairs(val) do
if option:scheme('minlength') then
if #v < option:scheme('minlength') then
local bc = "%s/bytecode/%s.lua" %{ self.schemedir, shm }
if not fs.access(bc) then
local bc = "%s/bytecode/%s.lua" %{ self.schemedir, shm }
if not fs.access(bc) then
- return false, so:error(ERR.SME_FIND(so, self.schemedir))
+ return false, so:error(ERR('SME_FIND', so, self.schemedir))
o = enum( scheme, nil, p, '(nil)', '(nil)', n )
end
o = enum( scheme, nil, p, '(nil)', '(nil)', n )
end
if k == "depends" then
s.depends = self:_read_dependency( v2, s.depends )
if not s.depends then
return false, scheme:error(
if k == "depends" then
s.depends = self:_read_dependency( v2, s.depends )
if not s.depends then
return false, scheme:error(
- ERR.SME_VBADPACK({scheme:sid(), '', v.name}, r[1])
+ ERR('SME_VBADPACK', {scheme:sid(), '', v.name}, r[1])
- ERR.SME_VBADSECT({scheme:sid(), '', v.name}, r[2])
+ ERR('SME_VBADSECT', {scheme:sid(), '', v.name}, r[2])
if k == "depends" then
t.depends = self:_read_dependency( v2, t.depends )
if not t.depends then
error(scheme:error(so:error(
if k == "depends" then
t.depends = self:_read_dependency( v2, t.depends )
if not t.depends then
error(scheme:error(so:error(
)))
end
elseif k == "validator" then
t.validators = self:_read_validator( v2, t.validators )
if not t.validators then
error(scheme:error(so:error(
)))
end
elseif k == "validator" then
t.validators = self:_read_validator( v2, t.validators )
if not t.validators then
error(scheme:error(so:error(
)))
end
elseif k == "valueof" then
local values, err = self:_read_reference( v2 )
if err then
error(scheme:error(so:error(
)))
end
elseif k == "valueof" then
local values, err = self:_read_reference( v2 )
if err then
error(scheme:error(so:error(
- ERR.SME_EBADPACK({scheme:sid(), '', '', v.value}, r[1])
+ ERR('SME_EBADPACK', {scheme:sid(), '', '', v.value}, r[1])
- ERR.SME_EBADSECT({scheme:sid(), '', '', v.value}, r[2])
+ ERR('SME_EBADSECT', {scheme:sid(), '', '', v.value}, r[2])
- ERR.SME_EBADOPT({scheme:sid(), '', '', v.value}, r[3])
+ ERR('SME_EBADOPT', {scheme:sid(), '', '', v.value}, r[3])
validator = self:_resolve_function( (value:gsub("^lua:","") ) )
elseif value:match("^regexp:") then
local pattern = value:gsub("^regexp:","")
validator = self:_resolve_function( (value:gsub("^lua:","") ) )
elseif value:match("^regexp:") then
local pattern = value:gsub("^regexp:","")
- validator = function( type, dtype, pack, sect, optn, ... )
- local values = { ... }
+ validator = function( type, dtype, pack, sect, optn, arg1, arg2, arg3, arg4, arg5 )
+ local values = { arg1, arg2, arg3, arg4, arg5 }
for _, v in ipairs(values) do
local ok, match =
pcall( string.match, v, pattern )
for _, v in ipairs(values) do
local ok, match =
pcall( string.match, v, pattern )
-function uvlitem.error(self, ...)
+function uvlitem.error(self, arg1, arg2, arg3, arg4, arg5)
- local errconst = { ERR.CONFIG, ERR.SECTION, ERR.OPTION, ERR.OPTION }
- self.e = errconst[#self.cref]( self )
+ local errconst = { 'CONFIG', 'SECTION', 'OPTION', 'OPTION' }
+ self.e = ERR( errconst[#self.cref], self )
-function scheme.error(self, ...)
- if not self.e then self.e = ERR.SCHEME( self ) end
- return self.e:child( ... )
+function scheme.error(self, arg1, arg2, arg3, arg4, arg5)
+ if not self.e then self.e = ERR( 'SCHEME', self ) end
+ return self.e:child( arg1, arg2, arg3, arg4, arg5 )