From 46222415352ac3b5a99570178a4ed46b759c2e82 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 30 Oct 2010 18:12:39 +0000 Subject: [PATCH] libs/web: introduce "uciname" datatype for cbi validation --- libs/web/htdocs/luci-static/resources/cbi.js | 4 ++++ libs/web/luasrc/cbi/datatypes.lua | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index b4137d486..8e2f62aea 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -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); + } }; diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 53a34547b..a9aba9549 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -204,3 +204,7 @@ function device( val, seen ) return false end + +function uciname(val) + return (val:match("^[a-zA-Z0-9_]+$") != nil) +end -- 2.11.0