libs/web: add list(...) datatype for space separated lists of arbritary datatypes
[project/luci.git] / libs / web / luasrc / cbi / datatypes.lua
index 93b29cb..9a3b735 100644 (file)
@@ -282,3 +282,17 @@ function neg(val, what)
 
        return false
 end
+
+function list(val, what, ...)
+       if type(val) == "string" and what and type(_M[what]) == "function" then
+               for val in val:gmatch("%S+") do
+                       if not _M[what](val, ...) then
+                               return false
+                       end
+               end
+
+               return true
+       end
+
+       return false
+end