X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fuvl%2Fluasrc%2Fuvl.lua;h=8275dbbe11706704e24bfe8b4bb7340ba17c61bb;hp=683d7a9bb5bf0d96604650319f27d329e13e12f9;hb=de80e2a708653e825434753a1b48559648942a3b;hpb=9e4c03a9c35a2ff29030a645bccf5984dd2978d6 diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua index 683d7a9bb..8275dbbe1 100644 --- a/libs/uvl/luasrc/uvl.lua +++ b/libs/uvl/luasrc/uvl.lua @@ -334,6 +334,30 @@ function UVL._validate_option( self, option, nodeps ) return false, option:error(ERR.OPT_DATATYPE(option, dt)) end end + + if option:scheme('minlength') then + if #val < option:scheme('minlength') then + return false, option:error(ERR.OPT_RANGE(option)) + end + end + + if option:scheme('maxlength') then + if #val > option:scheme('maxlength') then + return false, option:error(ERR.OPT_RANGE(option)) + end + end + + if option:scheme('minimum') then + if val < option:scheme('minimum') then + return false, option:error(ERR.OPT_RANGE(option)) + end + end + + if option:scheme('maximum') then + if val > option:scheme('maximum') then + return false, option:error(ERR.OPT_RANGE(option)) + end + end if not nodeps then local ok, err = dependencies.check( self, option ) @@ -582,6 +606,9 @@ function UVL._parse_var(self, scheme, k, v) t.valueof = type(v2) == "table" and v2 or {v2} elseif k == "required" then t[k] = _bool(v2) + elseif k == "minlength" or k == "maxlength" + or k == "minimum" or k == "maximum" then + t[k] = tonumber(v2) else t[k] = t[k] or v2 end