summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-11-04 23:49:20 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-11-04 23:49:20 +0000
commit03b4acea13eecf77f7540bef88a2a9901dfb03e0 (patch)
treeab7be623f2bb31419d80c8a63f6fe77f1efc710d
parent2b7f0d912e515d80c70baf2d920be520bed0103d (diff)
* luci/libs/uvl:
- recursively check error-tree of option-level dependencies - mask all non-critical errors when walking error tree
-rw-r--r--libs/uvl/luasrc/uvl.lua20
-rw-r--r--libs/uvl/luasrc/uvl/errors.lua6
2 files changed, 20 insertions, 6 deletions
diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua
index 3b3186eb2..b34f66bc1 100644
--- a/libs/uvl/luasrc/uvl.lua
+++ b/libs/uvl/luasrc/uvl.lua
@@ -295,7 +295,11 @@ function UVL._validate_option( self, option, nodeps )
if not nodeps then
local ok, err = dependencies.check( self, option )
if not ok then
- if not err:is_all(ERR.ERR_DEP_NOTEQUAL,ERR.ERR_DEP_NOVALUE) then
+ if not err:is_all(
+ ERR.ERR_OPT_REQUIRED,
+ ERR.ERR_DEP_NOTEQUAL,
+ ERR.ERR_DEP_NOVALUE
+ ) then
option:error(err)
return false, option:errors()
else
@@ -361,16 +365,22 @@ function UVL._validate_option( self, option, nodeps )
end
end
- v = tonumber(v)
-
+ local w = tonumber(v)
+
if option:scheme('minimum') then
- if not v or v < option:scheme('minimum') then
+ if not w or w < option:scheme('minimum') then
return false, option:error(ERR.OPT_RANGE(option))
end
end
if option:scheme('maximum') then
- if not v or v > option:scheme('maximum') then
+ if not w or w > option:scheme('maximum') then
+ return false, option:error(ERR.OPT_RANGE(option))
+ end
+ end
+
+ if option:scheme('max_nil') then
+ if v and (not w or w > tonumber(option:scheme('max_nil'))) then
return false, option:error(ERR.OPT_RANGE(option))
end
end
diff --git a/libs/uvl/luasrc/uvl/errors.lua b/libs/uvl/luasrc/uvl/errors.lua
index a575f4059..614100fce 100644
--- a/libs/uvl/luasrc/uvl/errors.lua
+++ b/libs/uvl/luasrc/uvl/errors.lua
@@ -193,7 +193,11 @@ function error.is_all(self, ...)
else
local equal = false
for _, c in ipairs(self.childs) do
- equal = util.contains(codes, c.code)
+ if c.childs then
+ equal = c:is_all(...)
+ else
+ equal = util.contains(codes, c.code)
+ end
end
return equal
end