diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-08-25 18:30:25 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-08-25 18:30:25 +0000 |
commit | 8e6d1e682afee81fb4199ad494195c23e4381af5 (patch) | |
tree | 33f4ca82e2fff93731aa7e00c8302e0585eb6803 /libs/uvl/luasrc/uvl.lua | |
parent | 1e6001c23542ff239f7ee77b17179522275781a1 (diff) |
* luci/libs: uvl: implement dependencies for enum values
Diffstat (limited to 'libs/uvl/luasrc/uvl.lua')
-rw-r--r-- | libs/uvl/luasrc/uvl.lua | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua index ed0bd13e1..aaeb875f5 100644 --- a/libs/uvl/luasrc/uvl.lua +++ b/libs/uvl/luasrc/uvl.lua @@ -352,7 +352,7 @@ function UVL._validate_option( self, option, nodeps ) return false, 'Value "%s" of given option "%s" is not defined in %s { %s }' %{ val or '<nil>', option:cid(), item.type, - table.concat( luci.util.keys(item.values), ", " ) } + table.concat( luci.util.keys(item.values or {}), ", " ) } end elseif item.type == "list" and val then if type(val) ~= "table" and STRICT_LIST_TYPE then @@ -609,6 +609,10 @@ function UVL._read_scheme_parts( self, scheme, schemes ) t.values[v.value] = v.title or v.value end + if not t.enum_depends then + t.enum_depends = { } + end + if v.default then _assert( not t.default, 'Enum "%s" in scheme "%s", section "%s" redeclares ' .. @@ -617,6 +621,16 @@ function UVL._read_scheme_parts( self, scheme, schemes ) t.default = v.value end + + if v.depends then + t.enum_depends[v.value] = _assert( + self:_read_dependency( + v.depends, t.enum_depends[v.value] + ), + 'Invalid reference "%s" in "%s.%s.%s.%s"', + v.depends, scheme, r[2], r[3], v.value + ) + end end end end |