* luci/libs: fix datatype validation of list values
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 18 Aug 2008 23:43:20 +0000 (23:43 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 18 Aug 2008 23:43:20 +0000 (23:43 +0000)
libs/uvl/luasrc/uvl.lua

index afa3cc71701aa7baba06ee39f53229a54c9406db..361cfc410fb0d0bb0fe238f4e7d924cb231fbf49 100644 (file)
@@ -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 '<nil>' ) ..
-                                               '" 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 '<nil>' ) ..
+                                                       '" of given option "' .. option:cid() ..
+                                                       '" does not validate as datatype "' ..
+                                                       item.datatype .. '"'
+                                       end
                                end
                        else
                                return false, 'Unknown datatype "' ..