libs/web: introduce "uciname" datatype for cbi validation
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 30 Oct 2010 18:12:39 +0000 (18:12 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 30 Oct 2010 18:12:39 +0000 (18:12 +0000)
libs/web/htdocs/luci-static/resources/cbi.js
libs/web/luasrc/cbi/datatypes.lua

index b4137d4..8e2f62a 100644 (file)
@@ -152,6 +152,10 @@ var cbi_validators = {
                        return (v.length == 5) || (v.length == 13);
        },
 
                        return (v.length == 5) || (v.length == 13);
        },
 
+       'uciname': function(v)
+       {
+               return (v.match(/^[a-zA-Z0-9_]+$/) != null);
+       }
 };
 
 
 };
 
 
index 53a3454..a9aba95 100644 (file)
@@ -204,3 +204,7 @@ function device( val, seen )
 
        return false
 end
 
        return false
 end
+
+function uciname(val)
+       return (val:match("^[a-zA-Z0-9_]+$") != nil)
+end