summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2017-02-09 16:58:07 +0200
committerHannu Nyman <hannu.nyman@iki.fi>2017-02-10 17:12:57 +0200
commit5e7b188ecb36e9ac2826b0d88c9fe6fa7a967786 (patch)
tree73e25c7391009353435209d5a9122a13be8f37b5 /modules
parent1f014bd2180b364bec4c3f6457f72a0621884f9a (diff)
luci-base: add hexstring datatype
Add datatype 'hexstring' for input validaiton datatypes. It will accept any hexadecimal string. (no length validation, as rangelength can be used for that.) Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi> (cherry picked from commit 11f23559e4be78f202aa55d811d5b58cb0ca0a78)
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/luasrc/cbi/datatypes.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/cbi/datatypes.lua b/modules/luci-base/luasrc/cbi/datatypes.lua
index 72b41ddad..0a180d366 100644
--- a/modules/luci-base/luasrc/cbi/datatypes.lua
+++ b/modules/luci-base/luasrc/cbi/datatypes.lua
@@ -267,6 +267,13 @@ function wepkey(val)
end
end
+function hexstring(val)
+ if val then
+ return (val:match("^[a-fA-F0-9]+$") ~= nil)
+ end
+ return false
+end
+
function string(val)
return true -- Everything qualifies as valid string
end