end
function hostname(val)
- if val and (#val < 254) and val.match(val, "^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") then
+ if val and (#val < 254) and (
+ val:match("^[a-zA-Z]+$") or
+ (val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$") and
+ val:match("[^0-9%.]"))
+ ) then
return true
end
return false
return hostname(val) or ipaddr(val)
end
+function network(val)
+ return uciname(val) or host(val)
+end
+
function wpakey(val)
if #val == 64 then
return (val:match("^[a-fA-F0-9]+$") ~= nil)
if type(v) == "string" then
v = v:gsub("^%s*!", "")
return (uciname(v) or ip4addr(v))
- end
+ end
end
function range(val, min, 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
+
+function list(val, what, ...)
+ if type(val) == "string" and what and type(_M[what]) == "function" then
+ for val in val:gmatch("%S+") do
+ if not _M[what](val, ...) then
+ return false
+ end
+ end
+
+ return true
+ end
+
+ return false
+end