From e5608ae6b2896b5ad7d9d7c8f73b6ec1efaaddcf Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 18 Aug 2008 23:43:20 +0000 Subject: [PATCH] * luci/libs: fix datatype validation of list values --- libs/uvl/luasrc/uvl.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua index afa3cc7170..361cfc410f 100644 --- a/libs/uvl/luasrc/uvl.lua +++ b/libs/uvl/luasrc/uvl.lua @@ -305,11 +305,15 @@ function UVL._validate_option( self, option, nodeps ) if item.datatype and val then if self.datatypes[item.datatype] then - if not self.datatypes[item.datatype]( val ) then - return false, 'Value "' .. ( val or '' ) .. - '" of given option "' .. option:cid() .. - '" does not validate as datatype "' .. - item.datatype .. '"' + val = ( type(val) == "table" and val or { val } ) + for i, v in ipairs(val) do + if not self.datatypes[item.datatype]( v ) then + return false, 'Value' .. ( #val>1 and ' #'..i or '' ) .. + ' "' .. ( v or '' ) .. + '" of given option "' .. option:cid() .. + '" does not validate as datatype "' .. + item.datatype .. '"' + end end else return false, 'Unknown datatype "' .. -- 2.30.2