'hostname': function(v)
{
if (v.length <= 253)
- return (v.match(/^[a-zA-Z0-9]+$/) != null ||
- v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) != null);
+ return (v.match(/^[a-zA-Z]+$/) != null ||
+ (v.match(/^[a-zA-Z0-9][a-zA-Z0-9\-.]*[a-zA-Z0-9]$/) &&
+ v.match(/[^0-9.]/)));
return false;
},
'neg_network_ip4addr': function(v)
{
v = v.replace(/^\s*!/, "");
- return cbi_validators.uciname(v) || cbi_validators.ip4addr(v);
+ return cbi_validators.uciname(v) || cbi_validators.ip4addr(v);
},
'range': function(v, args)
function hostname(val)
if val and (#val < 254) and (
- val:match("^[a-zA-Z0-9]+$") or
- val:match("^[a-zA-Z0-9][a-zA-Z0-9%-%.]*[a-zA-Z0-9]$")
+ 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
if type(v) == "string" then
v = v:gsub("^%s*!", "")
return (uciname(v) or ip4addr(v))
- end
+ end
end
function range(val, min, max)