projects
/
oweals
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libs/web: add range(min,max) datatype validator
[oweals/luci.git]
/
libs
/
web
/
luasrc
/
cbi
/
datatypes.lua
diff --git
a/libs/web/luasrc/cbi/datatypes.lua
b/libs/web/luasrc/cbi/datatypes.lua
index f8d81537793251f1d909931bb06c800818005b44..2fdb5802c409051e9f507b83318448aeefc6e0b3 100644
(file)
--- a/
libs/web/luasrc/cbi/datatypes.lua
+++ b/
libs/web/luasrc/cbi/datatypes.lua
@@
-208,3
+208,15
@@
end
function uciname(val)
return (val:match("^[a-zA-Z0-9_]+$") ~= nil)
end
function uciname(val)
return (val:match("^[a-zA-Z0-9_]+$") ~= nil)
end
+
+function range(val, min, max)
+ val = tonumber(val)
+ min = tonumber(min)
+ max = tonumber(max)
+
+ if val ~= nil and min ~= nil and max ~= nil then
+ return ((val >= min) and (val <= max))
+ end
+
+ return false
+end