Skip to content
Jo-Philipp Wich edited this page Jan 15, 2016 · 3 revisions

Datatypes are functions to dynamically validate the user input on the client side using Javascript.

Table of Contents

Definition

A datatype is defined as a

  • Standard validation:
  • Validation with arguments:
  • Combination of a meta type and mixed types and strings:

Meta types

and

Makes it possible to validate against one or more datatypes in the same field.

Example usage:

  • Would allow using integers from 0 to 2048, no decimals.

or

Makes it possible to use different datatypes in the same field.

Example usage:

  • Would allow using -1, a positive number except from 0 to 29 and allow the term infinity to be used.

neg

Allow using an exclamation mark in front of the value.

Example usage:

list

Allow the usage of a space separated multi-value.

Types

bool

Verify if the value is either 1, yes, on, true or 0, no, off, false.

Example:

uinteger

Verify if the value is a positive (unsigned) number and doesn't contain decimals.

Example:

integer

Verify if the value is a number doesn't contain decimals.

Example:

ufloat

Verify if the value is a positive number.

Example:

float

Verify if the value is a number.

Example:

ipaddr

Verify if the value is an IP address, either IPv4 or IPv6.

ip4addr

Verify if the value is an IPv4 address.

Example:

ip4prefix

Verify if the value is an IPv4 address and allow to add a mask.

Example:

ip6addr

Verify if the value is an IPv6 address.

Example:

ip6prefix

Verify if the value is an IPv6 address and allow to add a mask.

Example:

port

Verify if the value is a port between 0 and 65535.

Example:

portrange

Verify if the value contains one or more port separated by a dash.

Example:

macaddr

Verify if the value is a valid MAC address separated by colons. The address may contain uppercase and lowercase hexadecimal characters.

Examples:

hostname

Verify if the value is a valid DNS domain name or hostname. The hostname can contain uppercase and lowercase alphanumerical characters, underscore, dash and dots. Hostname cannot start with a dash or end with a dot.

Example:

host

Verify if the value is a valid hostname or IP address.

Example:

network

Same as host but also allows UCI network names found in the Network, Interfaces page.

Example:

wpakey

Verify if the value is a valid WPA pre-shared key, from 8 to 63 characters or a valid WPA key containing exactly 64 hexadecimal characters.

Example:

wepkey

Verify if the value is a valid 40 bits or 104 bit WEP key or string. If the WEP key is defined as a string, it must start with s: and contain either 5 or 13 characters. If the key is defined as hexadecimal, it must contain exactly 10 or 26 hexadecimal characters.

Example:

string

Does not validate anything.

directory

Tests on the server side whether the value is a path pointing to a directory or a path pointing to a symlink of a directory.

Example:

file

Tests on the server side whether the value is a path pointing to a directory or a path pointing to a symlink of a directory.

Example:

device

Tests on the server side whether the value is a path pointing to a device or a path pointing to a symlink of a device.

Example:

uciname

Verify if the value is a valid UCI name.

Example:

range(min, max)

Verify if the value is a valid number between min and max.

Example:

min(min)

Verify if the value is a valid number above or equal to min.

Example:

max(max)

Verify if the value is a valid number below or equal to max.

Example:

rangelength(min, max)

Verify if the value fits in length between min characters and max characters.

Example:

minlength(min)

Verify if the value has at least min characters or more.

Example:

maxlength(max)

Verify if the value has at most max characters or less.

Example:

phonedigit

Verify if the value qualifies as a phone number containing digits from 0 to 9, star, or pound.

Example:

Clone this wiki locally