Fixed new UVL options
This commit is contained in:
parent
096ff29755
commit
9d67f6db01
1 changed files with 23 additions and 18 deletions
|
@ -335,27 +335,32 @@ function UVL._validate_option( self, option, nodeps )
|
|||
end
|
||||
end
|
||||
|
||||
if option:scheme('minlength') then
|
||||
if #val < option:scheme('minlength') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
val = ( type(val) == "table" and val or { val } )
|
||||
for _, v in ipairs(val) do
|
||||
if option:scheme('minlength') then
|
||||
if #v < option:scheme('minlength') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if option:scheme('maxlength') then
|
||||
if #val > option:scheme('maxlength') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
|
||||
if option:scheme('maxlength') then
|
||||
if #v > option:scheme('maxlength') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if option:scheme('minimum') then
|
||||
if val < option:scheme('minimum') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
|
||||
v = tonumber(v)
|
||||
|
||||
if option:scheme('minimum') then
|
||||
if not v or v < option:scheme('minimum') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if option:scheme('maximum') then
|
||||
if val > option:scheme('maximum') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
|
||||
if option:scheme('maximum') then
|
||||
if not v or v > option:scheme('maximum') then
|
||||
return false, option:error(ERR.OPT_RANGE(option))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue