summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-09-04 12:07:43 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-09-04 12:07:43 +0000
commit794094caa20d922d968b4615f44a189f25f48a5e (patch)
tree0c0e4869cdd52d92a8fd8c177c1d19afeb662c1d /libs/web/luasrc
parent704824c9566b2d36d6102078250013f71ce054f6 (diff)
libs/web: add "neg()" cbi datatype to negate arbritary types, e.g. "neg(hostname)" would allow "!example.com"
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r--libs/web/luasrc/cbi/datatypes.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua
index 6640db6392..fc3048e37e 100644
--- a/libs/web/luasrc/cbi/datatypes.lua
+++ b/libs/web/luasrc/cbi/datatypes.lua
@@ -267,3 +267,11 @@ function max(val, max)
return false
end
+
+function neg(val, what)
+ if what and type(_M[what]) == "function" then
+ return _M[what](val:gsub("^%s*!%s*", ""))
+ end
+
+ return false
+end