From 11f23559e4be78f202aa55d811d5b58cb0ca0a78 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Thu, 9 Feb 2017 16:58:07 +0200 Subject: 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 --- modules/luci-base/luasrc/cbi/datatypes.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/luci-base/luasrc/cbi') 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 -- cgit v1.2.3