Collection of type handlers. Each function consumes this.value and returns this.assert to report errors.
All functions return the result of assert().
- Source
Methods
and() → {boolean}
Logical AND && to build more complex expressions. Enforces all types on the input string.
See also or
| Name | Type | Description |
|---|---|---|
...args | string |
- Source
- Type:
- boolean
cidr(negativeopt) → {boolean}
Assert a IPv4/6 CIDR.
| Name | Type | Attributes | Description |
|---|---|---|---|
negative | boolean | <optional> | allow netmask forms with |
- Source
- Type:
- boolean
cidr4(negativeopt) → {boolean}
Assert a IPv4 CIDR.
| Name | Type | Attributes | Description |
|---|---|---|---|
negative | boolean | <optional> | allow netmask forms with |
- Source
- Type:
- boolean
cidr6(negativeopt) → {boolean}
Assert a IPv6 CIDR.
| Name | Type | Attributes | Description |
|---|---|---|---|
negative | boolean | <optional> | allow netmask forms with |
- Source
- Type:
- boolean
dateyyyymmdd() → {boolean}
Assert a string of the form YYYY-MM-DD.
- Source
- Type:
- boolean
device() → {boolean}
Assert a device string. This is a hold-over from Lua to maintain compatibility and is a stub function.
- Source
Always returns true.
- Type:
- boolean
directory() → {boolean}
Assert a directory string. This is a hold-over from Lua to maintain compatibility and is a stub function.
- Source
Always returns true.
- Type:
- boolean
file() → {boolean}
Assert a file string. This is a hold-over from Lua to maintain compatibility and is a stub function.
- Source
Always returns true.
- Type:
- boolean
float() → {boolean}
Assert a signed float value (+/-).
- Source
- Type:
- boolean
hexstring() → {boolean}
Assert a hexadecimal string.
- Source
- Type:
- boolean
FFFE // valid
FFF // invalidhost(ipv4onlyopt) → {boolean}
Assert a valid hostname or IP address.
| Name | Type | Attributes | Description |
|---|---|---|---|
ipv4only | boolean | <optional> | enforce IPv4 IPs only. |
- Source
- Type:
- boolean
hostname(strictopt) → {boolean}
Validate hostname according to common rules.
| Name | Type | Attributes | Description |
|---|---|---|---|
strict | boolean | <optional> | reject leading underscores. |
- Source
- Type:
- boolean
hostport(ipv4onlyopt) → {boolean}
Assert a valid host:port.
| Name | Type | Attributes | Description |
|---|---|---|---|
ipv4only | boolean | <optional> | restrict to IPv4 IPs only. |
- Source
- Type:
- boolean
integer() → {boolean}
Assert a signed integer value (+/-).
- Source
- Type:
- boolean
ip4addr(nomaskopt) → {boolean}
Assert an IPv4 address.
| Name | Type | Attributes | Description |
|---|---|---|---|
nomask | string | <optional> | reject a |
- Source
- Type:
- boolean
ip4addrport(ipv4onlyopt) → {boolean}
Assert a valid IPv4 address:port. E.g. 192.0.2.10:80
| Name | Type | Attributes | Description |
|---|---|---|---|
ipv4only | boolean | <optional> | restrict to IPv4 IPs only. |
- Source
- Type:
- boolean
ip4prefix() → {boolean}
Assert an IPv4 prefix.
- Source
- Type:
- boolean
ip6addr(nomaskopt) → {boolean}
Assert an IPv6 address.
| Name | Type | Attributes | Description |
|---|---|---|---|
nomask | string | <optional> | reject a |
- Source
- Type:
- boolean
ip6hostid() → {boolean}
Assert a IPv6 host ID.
- Source
- Type:
- boolean
ip6ll(nomaskopt) → {boolean}
Assert an IPv6 Link Local address.
| Name | Type | Attributes | Description |
|---|---|---|---|
nomask | string | <optional> | reject a |
- Source
- Type:
- boolean
ip6prefix() → {boolean}
Assert an IPv6 prefix.
- Source
- Type:
- boolean
ip6ula(nomaskopt) → {boolean}
Assert an IPv6 UL address.
| Name | Type | Attributes | Description |
|---|---|---|---|
nomask | string | <optional> | reject a |
- Source
- Type:
- boolean
ipaddr(nomaskopt) → {boolean}
Assert an IPv4/6 address.
| Name | Type | Attributes | Description |
|---|---|---|---|
nomask | string | <optional> | reject a |
- Source
- Type:
- boolean
ipaddrport(bracketopt) → {boolean}
Assert a valid IPv4/6 address:port. E.g. 192.0.2.10:80 or [2001:db8:f00d:cafe::1]:8080
| Name | Type | Attributes | Description |
|---|---|---|---|
bracket | boolean | <optional> | mandate bracketed [IPv6] URI form IPs. |
- Source
- Type:
- boolean
ipmask(negativeopt) → {boolean}
Assert an IPv4/6 network in address/netmask (CIDR or mask) notation.
| Name | Type | Attributes | Description |
|---|---|---|---|
negative | boolean | <optional> | allow netmask forms with |
- Source
- Type:
- boolean
ipmask4(negativeopt) → {boolean}
Assert an IPv4 network in address/netmask (CIDR or mask) notation.
| Name | Type | Attributes | Description |
|---|---|---|---|
negative | boolean | <optional> | allow netmask forms with |
- Source
- Type:
- boolean
ipmask6(negativeopt) → {boolean}
Assert an IPv6 network in address/netmask (CIDR or mask) notation.
| Name | Type | Attributes | Description |
|---|---|---|---|
negative | boolean | <optional> | allow netmask forms with |
- Source
- Type:
- boolean
ipnet4() → {boolean}
Assert an IPv4 network in address/netmask notation. E.g. 192.0.2.1/255.255.255.0
- Source
- Type:
- boolean
ipnet6() → {boolean}
Assert an IPv6 network in address/netmask notation. E.g. 2001:db8:dead:beef::0001/ffff:ffff:ffff:ffff::
- Source
- Type:
- boolean
iprange() → {boolean}
Assert a valid IPv4/6 address range.
- Source
- Type:
- boolean
iprange4() → {boolean}
Assert a valid IPv4 address range. E.g. 192.0.2.1-192.0.2.254.
- Source
- Type:
- boolean
iprange6() → {boolean}
Assert a valid IPv6 address range. E.g. 2001:db8:0f00:0000::-2001:db8:0f00:0000:ffff:ffff:ffff:ffff.
- Source
- Type:
- boolean
length(len) → {boolean}
Assert a string of bytelen length len characters.
| Name | Type | Description |
|---|---|---|
len | string | set the length. |
- Source
- Type:
- boolean
list(subvalidator, subargs) → {boolean}
Assert a list of a type.
| Name | Type | Description |
|---|---|---|
subvalidator | string | |
subargs | string | arguments to pass to the |
- Source
- Type:
- boolean
list(string)macaddr(multicastopt) → {boolean}
Assert a valid (multicast) MAC address.
| Name | Type | Attributes | Description |
|---|---|---|---|
multicast | boolean | <optional> | enforce a multicast MAC address. |
- Source
- Type:
- boolean
max(max) → {boolean}
Assert a decimal value lesser or equal to max.
| Name | Type | Description |
|---|---|---|
max | string | set end of range. |
- Source
- Type:
- boolean
maxlength(max) → {boolean}
Assert a value of bytelen with at most max characters.
| Name | Type | Description |
|---|---|---|
max | string | set the max length. |
- Source
- Type:
- boolean
min(min) → {boolean}
Assert a decimal value greater or equal to min.
| Name | Type | Description |
|---|---|---|
min | string | set start of range. |
- Source
- Type:
- boolean
minlength(min) → {boolean}
Assert a value of bytelen with at least min characters.
| Name | Type | Description |
|---|---|---|
min | string | set the min length. |
- Source
- Type:
- boolean
neg() → {boolean}
Assert any type, optionally preceded by !.
Example:list(neg(macaddr)) mandates a list of MAC values, which may also be prefixed with a single !; the MAC strings are validated after ! are removed from all entries.
01:02:03:04:05:06
!01:02:03:04:05:07
01:02:03:04:05:08
| Name | Type | Description |
|---|---|---|
...args | string |
- Source
- Type:
- boolean
netdevname() → {boolean}
Assert a valid network device name between 1 and 15 characters not containing ":", "/", "%" or spaces.
- Source
- Type:
- boolean
network() → {boolean}
Assert a valid UCI identifier, hostname or IP address range.
- Source
- Type:
- boolean
or() → {boolean}
Logical OR || to build a more complex expression. Allows multiple types within a single field.
See also and
| Name | Type | Description |
|---|---|---|
...args | string |
- Source
- Type:
- boolean
phonedigit() → {boolean}
Assert a valid phone number dial string: [0-9*#!.]+.
- Source
- Type:
- boolean
port() → {boolean}
Assert a valid port value where 0 <= port <= 65535.
- Source
- Type:
- boolean
portrange() → {boolean}
Assert a valid port or port range (port1-port2) where both ports are positive integers, port1 <= port2 and port2 <= 65535 (2^16 - 1).
- Source
- Type:
- boolean
range(min, max) → {boolean}
Assert a decimal value between min and max.
| Name | Type | Description |
|---|---|---|
min | string | set start of range. |
max | string | set end of range. |
- Source
- Type:
- boolean
range(-253, 253) // assert a value between -253 and +253
'range(%u,%u)'.format(min_vid, feat.vid_option ? 4094 : num_vlans - 1);
// assert values calculated at runtime for VLAN IDs.rangelength(min, max) → {boolean}
Assert a string value of bytelen length between min and max characters.
| Name | Type | Description |
|---|---|---|
min | string | set the min length. |
max | string | set the max length. |
- Source
- Type:
- boolean
sep(str) → {boolean}
Define a string separator sep for use in tuple.
| Name | Type | Description |
|---|---|---|
str | string | define the separator string |
- Source
- Type:
- boolean
string(paramopt) → {boolean}
Assert a string type, optionally matching param.
| Name | Type | Attributes | Description |
|---|---|---|---|
param | string | <optional> | define an optional exact string |
- Source
- Type:
- boolean
timehhmmss() → {boolean}
Assert a string of the form HH:MM:SS.
- Source
- Type:
- boolean
tuple(…types, sep()opt) → {boolean}
Tuple validator: accepts 1-N tokens separated by a given separator sep (whitespace by default if sep is omitted) which will be validated against the 1-N types.
This differs from and by first splitting the input and applying each validator function sequentially on the resulting array of the split string, whereby the first type applies to the first value element, the second to the second, and so on, to define a concrete order.
sep can appear at any position in the list.
| Name | Type | Attributes | Description |
|---|---|---|---|
types | function | <repeatable> | |
sep() | string | <optional> | function to define split separator string. |
- Source
- Type:
- boolean
tuple(ipaddr,port) // "192.0.2.1 88"
tuple(host,port,sep(',')) // "taurus,8000"
tuple(port,port,port,sep('-')) // "33-45-78"ucifw4zonename() → {boolean}
Assert a valid fw4 zone name UCI identifier: [a-zA-Z_][a-zA-Z0-9_]+
- Source
- Type:
- boolean
uciname() → {boolean}
Assert a valid UCI identifier: [a-zA-Z0-9_]+.
- Source
- Type:
- boolean
ufloat() → {boolean}
Assert an unsigned float value (+).
- Source
- Type:
- boolean
uinteger() → {boolean}
Assert an unsigned integer value (+).
- Source
- Type:
- boolean
unique(subvalidator, subargs) → {boolean}
Assert unique values among lists.
| Name | Type | Description |
|---|---|---|
subvalidator | string | |
subargs | string | arguments to subvalidators |
- Source
- Type:
- boolean
wepkey() → {boolean}
Assert a valid (hexadecimal) WEP key.
- Source
- Type:
- boolean
wpakey() → {boolean}
Assert a valid (hexadecimal) WPA key of 8 <= length <= 63, or hex if length == 64.
- Source
- Type:
- boolean