if not nodeps then
local ok, err = dependencies.check( self, option )
if not ok then
- -- XXX: maybe this needs to be more specific
- if not err:is(ERR.ERR_DEP_NOTEQUAL) and
- not err:is(ERR.ERR_DEP_NOVALUE)
+ if not err:is_all(ERR.ERR_DEP_NOTEQUAL) and
+ not err:is_all(ERR.ERR_DEP_NOVALUE)
then
option:error(err)
return false, option:errors()
for v in r:gmatch("[^.]+") do
ref[#ref+1] = (v:gsub( "%$(.+)", vars ))
end
-
+
if #ref < 2 then
table.insert(ref, 1, s or '$section')
end
for _, dep in ipairs(object:scheme('depends')) do
local subcondition = true
- for k, v in pairs(dep) do
+ local score = 0
+
+ for k, v in util.spairs(
+ dep, function(a, b) return type(dep[a]) == "string" end
+ ) do
-- XXX: better error
local ref = _parse_reference( k, unpack(object.cref) )
derr:child(
type(v) == "boolean"
and ERR.DEP_NOVALUE(option, depstr)
- or ERR.DEP_NOTEQUAL(option, {depstr, v})
+ or ERR.DEP_NOTEQUAL(option, {depstr, v}),
+ score
)
- break
+ --break
+ else
+ score = score + ( type(v) == "boolean" and 1 or 10 )
end
else
subcondition = false
local util = require "luci.util"
local string = require "string"
-local ipairs, error, type = ipairs, error, type
+local ipairs, error, type = ipairs, error, type
local tonumber, unpack = tonumber, unpack
end
return false
end
+
+function error.is_all(self, code)
+ if self.code == code then
+ return true
+ else
+ local equal = false
+ for _, c in ipairs(self.childs) do
+ equal = ( c.code == code )
+ end
+ return equal
+ end
+end