diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2010-12-05 00:19:09 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2010-12-05 00:19:09 +0000 |
commit | 090ce4f17e13e81a459e1ef0e9d6db974d97579c (patch) | |
tree | 403e87aff1873093f8c2816d64f466caa65a0c15 /libs/web/luasrc/cbi | |
parent | 8c9acb01f4e345a096042a994e1655b21689a3cf (diff) |
libs/web: add float and ufloat datatypes for field validation
Diffstat (limited to 'libs/web/luasrc/cbi')
-rw-r--r-- | libs/web/luasrc/cbi/datatypes.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua index 2fdb5802c4..62f06c4b40 100644 --- a/libs/web/luasrc/cbi/datatypes.lua +++ b/libs/web/luasrc/cbi/datatypes.lua @@ -35,7 +35,7 @@ function bool(val) return false end -function uint(val) +function uinteger(val) local n = tonumber(val) if n ~= nil and math.floor(n) == n and n >= 0 then return true @@ -44,7 +44,7 @@ function uint(val) return false end -function int(val) +function integer(val) local n = tonumber(val) if n ~= nil and math.floor(n) == n then return true @@ -53,6 +53,11 @@ function int(val) return false end +function ufloat(val) + local n = tonumber(val) + return ( n ~= nil and n >= 0 ) +end + function float(val) return ( tonumber(val) ~= nil ) end |