summaryrefslogtreecommitdiffhomepage
path: root/libs/uvl/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/uvl/luasrc')
-rw-r--r--libs/uvl/luasrc/uvl.lua17
-rw-r--r--libs/uvl/luasrc/uvl/errors.lua25
2 files changed, 30 insertions, 12 deletions
diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua
index 4ff6e7f3c1..66e7eeaead 100644
--- a/libs/uvl/luasrc/uvl.lua
+++ b/libs/uvl/luasrc/uvl.lua
@@ -246,7 +246,12 @@ function UVL._validate_section( self, section )
for _, v in ipairs(section:variables()) do
local ok, err = self:_validate_option( v )
- if not ok then
+ if not ok and (
+ v:scheme('required') or v:scheme('type') == "enum" or (
+ not err:is(ERR.ERR_DEP_NOTEQUAL) and
+ not err:is(ERR.ERR_DEP_NOVALUE)
+ )
+ ) then
section:error(err)
end
end
@@ -263,7 +268,7 @@ function UVL._validate_section( self, section )
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_NOTFOUND(oo))
+ section:error(ERR.OPT_UNKNOWN(oo))
end
end
end
@@ -292,9 +297,9 @@ function UVL._validate_option( self, option, nodeps )
not option:scheme('values')[val]
then
return false, option:error( ERR.OPT_BADVALUE(
- option, { val, table.concat(
- luci.util.keys(option:scheme('values') or {}), ", "
- ) }
+ option, luci.util.serialize_data(
+ luci.util.keys(option:scheme('values') or {})
+ )
) )
end
elseif option:scheme('type') == "list" then
@@ -309,7 +314,7 @@ function UVL._validate_option( self, option, nodeps )
for i, v in ipairs(val) do
if not self.datatypes[dt]( v ) then
return false, option:error(
- ERR.OPT_INVVALUE(option, {v, dt})
+ ERR.OPT_INVVALUE(option, dt)
)
end
end
diff --git a/libs/uvl/luasrc/uvl/errors.lua b/libs/uvl/luasrc/uvl/errors.lua
index d667848594..b7afcfb0b7 100644
--- a/libs/uvl/luasrc/uvl/errors.lua
+++ b/libs/uvl/luasrc/uvl/errors.lua
@@ -22,8 +22,8 @@ ERRCODES = {
{ 'SCHEME', 'Error in scheme "%p":\n%c' },
{ 'CONFIG', 'Error in config "%p":\n%c' },
- { 'SECTION', 'Error in section "%p.%s":\n%c' },
- { 'OPTION', 'Error in option "%p.%s.%o":\n%c' },
+ { 'SECTION', 'Error in section "%i" (%I):\n%c' },
+ { 'OPTION', 'Error in option "%i" (%I):\n%c' },
{ 'REFERENCE', 'Option "%p.%s.%o" has invalid reference specification %1:\n%c' },
{ 'DEPENDENCY', 'In dependency check for %t "%i":\n%c' },
@@ -43,16 +43,16 @@ ERRCODES = {
{ 'SME_EBADTYPE', 'Enum "%v" in scheme "%p" references non-enum option "%p.%s.%o"' },
{ 'SME_EBADDEF', 'Enum "%v" in scheme "%p" redeclares the default value of "%p.%s.%o"' },
- { 'SECT_UNKNOWN', 'Section "%p.%s" not found in scheme' },
+ { 'SECT_UNKNOWN', 'Section "%i" (%I) not found in scheme' },
{ 'SECT_REQUIRED', 'Required section "%p.%S" not found in config' },
{ 'SECT_UNIQUE', 'Unique section "%p.%S" occurs multiple times in config' },
{ 'SECT_NAMED', 'The section of type "%p.%S" is stored anonymously in config but must be named' },
{ 'SECT_NOTFOUND', 'Section "%p.%s" not found in config' },
- { 'OPT_UNKNOWN', 'Option "%1" not found in scheme' },
+ { 'OPT_UNKNOWN', 'Option "%i" (%I) not found in scheme' },
{ 'OPT_REQUIRED', 'Required option "%i" has no value' },
- { 'OPT_BADVALUE', 'Value "%1" of option "%i" is not defined in %t { %2 }' },
- { 'OPT_INVVALUE', 'Value "%1" of given option "%i" does not validate as datatype "%2"' },
+ { 'OPT_BADVALUE', 'Value "%v" of option "%i" is not defined in enum %1' },
+ { 'OPT_INVVALUE', 'Value "%v" of given option "%i" does not validate as datatype "%1"' },
{ 'OPT_NOTLIST', 'Option "%i" is defined as list but stored as plain value' },
{ 'OPT_DATATYPE', 'Option "%i" has unknown datatype "%1"' },
{ 'OPT_NOTFOUND', 'Option "%p.%s.%o" not found in config' },
@@ -146,3 +146,16 @@ function error.sid(self)
( self.option and '.' .. self.option or '' ) ..
( self.value and '.' .. self.value or '' )
end
+
+function error.is(self, code)
+ if self.code == code then
+ return true
+ elseif self.childs then
+ for _, c in ipairs(self.childs) do
+ if c:is(code) then
+ return true
+ end
+ end
+ end
+ return false
+end