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