Built-in filters

Up-to-date API doc.

#alnum
Alphanumeric value. Matches /^[0-9A-Za-z]+$/.
#choice
A white list of case-sensitive (optionally insensitive) values.
#color
Any string that looks like a CSS color. Matches hex values such as #123 or #123456, color names such as red (or any string composed of letters from a to z) and CSS rgb() values such as rgb(12, 34, 56).
#email
A well-formed email address. Uses ext/filter's FILTER_VALIDATE_EMAIL filter. The JavaScript version is much more lenient.
#false
Dummy filter that systematically invalidates the attribute value.
#float
A decimal value. Uses ext/filter's FILTER_VALIDATE_FLOAT filter. Returns a float, not a string.
#fontfamily
A CSS font-family value. More restrictive than the CSS specs. Font names can only contain ASCII letters and digits. They can be quoted and separated by a comma optionally surrounded with spaces.
#hashmap
Requires an associative array that maps strings to their replacement. Case-sensitive. Preserves unknown values by default.
#identifier
A string of letters, numbers, dashes and underscores. Matches /^[-0-9A-Za-z_]+$/.
#int
An integer value. Uses ext/filter's FILTER_VALIDATE_INT filter. Returns an integer, not a string.
#ip
A valid IPv4 or IPv6 address. Uses ext/filter's FILTER_VALIDATE_IP filter.
#ipport
A valid IPv4 or IPv6 address with a port such as 127.0.0.1:80 or [ff02::1]:80. Uses ext/filter's FILTER_VALIDATE_IP filter for the IP part.
#ipv4
A valid IPv4 address. Uses ext/filter's FILTER_VALIDATE_IP filter with the FILTER_FLAG_IPV4 flag.
#ipv6
A valid IPv6 address. Uses ext/filter's FILTER_VALIDATE_IP filter with the FILTER_FLAG_IPV6 flag.
#map
Requires an associative array that maps strings to their replacement. Case-insensitive by default. Preserves unknown values by default.
#number
A string made of digits. Matches /^[0-9]+$/. Note that unlike #int, "0123" is a valid number. Returns a string.
#range
An integer value, adjusted for given range. Requires a min option and a max option. Uses ext/filter's FILTER_VALIDATE_INT filter. Values outside of range are adjusted to closest valid value. Returns an integer.
#regexp
A string that matches given regexp. Requires a regexp option.
#simpletext
A string that matches /^[- +,.0-9A-Za-z_]+$/.
#uint
An unsigned integer value. Same as #int, but rejects values less than 0.
#url
A valid URL as per RFC3986, with some small differences. Emphasis is on security features rather than strict compliance. Trims surrounding whitespace and encodes illegal characters to facilitate compliance with HTML specs. Uses the settings from UrlConfig. Punycodes IDNs if idn_to_ascii() is available. URL-encodes non-ASCII characters. Also URL-encodes the following characters "'()<> as well as line terminators to make the URL safer to use in CSS and JavaScript. Validates scheme against allowed schemes. Validates host against the white- and black- lists of hosts. Supports relative URLs.