Class FormatRules

Summary

Fully Qualified Name: CodeIgniter\Validation\FormatRules

Description

Format validation Rules.

Methods

Name Description Defined By
alpha() Alpha FormatRules
alpha_dash() Alphanumeric with underscores and dashes FormatRules
alpha_numeric() Alphanumeric FormatRules
alpha_numeric_punct() Alphanumeric, spaces, and a limited set of punctuation characters. FormatRules
alpha_numeric_space() Alphanumeric w/ spaces FormatRules
alpha_space() Alpha with spaces. FormatRules
decimal() Decimal number FormatRules
hex() String of hexidecimal characters FormatRules
integer() Integer FormatRules
is_natural() Is a Natural number (0,1,2,3, etc.) FormatRules
is_natural_no_zero() Is a Natural number, but not a zero (1,2,3, etc.) FormatRules
numeric() Numeric FormatRules
regex_match() Compares value against a regular expression pattern. FormatRules
string() Any type of string FormatRules
timezone() Validates that the string is a valid timezone as per the timezone_identifiers_list function. FormatRules
valid_base64() Valid Base64 FormatRules
valid_date() Checks for a valid date and matches a given date format FormatRules
valid_email() Checks for a correctly formatted email address FormatRules
valid_emails() Validate a comma-separated list of email addresses. FormatRules
valid_ip() Validate an IP address (human readable format or binary string - inet_pton) FormatRules
valid_json() Valid JSON FormatRules
valid_url() Checks a URL to ensure it's formed correctly. FormatRules

Method Details

alpha()

Alpha

Parameter Name Type Description
$str string

Returns: bool

alpha_dash()

Alphanumeric with underscores and dashes

Parameter Name Type Description
$str string

Returns: bool

alpha_numeric()

Alphanumeric

Parameter Name Type Description
$str string

Returns: bool

alpha_numeric_punct()

Alphanumeric, spaces, and a limited set of punctuation characters.

Accepted punctuation characters are: ~ tilde, ! exclamation,

number, $ dollar, % percent, & ampersand, * asterisk, - dash,

underscore, + plus, = equals, | vertical bar, : colon, . period ~ ! # $ % & * - + = | : .

Parameter Name Type Description
$str string

Returns: bool

alpha_numeric_space()

Alphanumeric w/ spaces

Parameter Name Type Description
$str string

Returns: bool

alpha_space()

Alpha with spaces.

Parameter Name Type Description
$value string Value.

Returns: bool True if alpha with spaces, else false.

decimal()

Decimal number

Parameter Name Type Description
$str string

Returns: bool

hex()

String of hexidecimal characters

Parameter Name Type Description
$str string

Returns: bool

integer()

Integer

Parameter Name Type Description
$str string

Returns: bool

is_natural()

Is a Natural number (0,1,2,3, etc.)

Parameter Name Type Description
$str string

Returns: bool

is_natural_no_zero()

Is a Natural number, but not a zero (1,2,3, etc.)

Parameter Name Type Description
$str string

Returns: bool

numeric()

Numeric

Parameter Name Type Description
$str string

Returns: bool

regex_match()

Compares value against a regular expression pattern.

Parameter Name Type Description
$str string
$pattern string

Returns: bool

string()

Any type of string

Note: we specifically do NOT type hint $str here so that it doesn't convert numbers into strings.

Parameter Name Type Description
$str string|null

Returns: bool

timezone()

Validates that the string is a valid timezone as per the timezone_identifiers_list function.

Parameter Name Type Description
$str string

Returns: bool

valid_base64()

Valid Base64

Tests a string for characters outside of the Base64 alphabet as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045

Parameter Name Type Description
$str string

Returns: bool

valid_date()

Checks for a valid date and matches a given date format

Parameter Name Type Description
$str string
$format string

Returns: bool

valid_email()

Checks for a correctly formatted email address

Parameter Name Type Description
$str string

Returns: bool

valid_emails()

Validate a comma-separated list of email addresses.

Example: valid_emails[one@example.com,two@example.com]

Parameter Name Type Description
$str string

Returns: bool

valid_ip()

Validate an IP address (human readable format or binary string - inet_pton)

Parameter Name Type Description
$ip string IP
$which string IP

Returns: bool

valid_json()

Valid JSON

Parameter Name Type Description
$str string

Returns: bool

valid_url()

Checks a URL to ensure it's formed correctly.

Parameter Name Type Description
$str string

Returns: bool

Top