CodeIgniter v4.5 API

FormatRules
in package

Format validation Rules.

Tags
see
FormatRulesTest

Table of Contents

Properties

$nonStrictFormatRules  : FormatRules

Methods

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

Properties

Methods

alpha()

Alpha

public alpha([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

alpha_dash()

Alphanumeric with underscores and dashes

public alpha_dash([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

alpha_numeric()

Alphanumeric

public alpha_numeric([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

alpha_numeric_punct()

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

public alpha_numeric_punct(array<string|int, mixed>|bool|float|int|object|string|null $str) : bool

Accepted punctuation characters are: ~ tilde, ! exclamation,

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

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

Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null
Return values
bool

alpha_numeric_space()

Alphanumeric w/ spaces

public alpha_numeric_space([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

alpha_space()

Alpha with spaces.

public alpha_space([array<string|int, mixed>|bool|float|int|object|string|null $value = null ]) : bool
Parameters
$value : array<string|int, mixed>|bool|float|int|object|string|null = null

Value.

Return values
bool

True if alpha with spaces, else false.

decimal()

Decimal number

public decimal([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

hex()

String of hexidecimal characters

public hex([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

integer()

Integer

public integer([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

is_natural()

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

public is_natural([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

is_natural_no_zero()

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

public is_natural_no_zero([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

numeric()

Numeric

public numeric([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

regex_match()

Compares value against a regular expression pattern.

public regex_match(array<string|int, mixed>|bool|float|int|object|string|null $str, string $pattern) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null
$pattern : string
Return values
bool

string()

Any type of string

public string([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

timezone()

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

public timezone([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Tags
see
http://php.net/manual/en/datetimezone.listidentifiers.php
Return values
bool

valid_base64()

Valid Base64

public valid_base64([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool

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

Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

valid_date()

Checks for a valid date and matches a given date format

public valid_date([array<string|int, mixed>|bool|float|int|object|string|null $str = null ][, string|null $format = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
$format : string|null = null
Return values
bool

valid_email()

Checks for a correctly formatted email address

public valid_email([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

valid_emails()

Validate a comma-separated list of email addresses.

public valid_emails([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool

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

Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

valid_ip()

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

public valid_ip([array<string|int, mixed>|bool|float|int|object|string|null $ip = null ][, string|null $which = null ]) : bool
Parameters
$ip : array<string|int, mixed>|bool|float|int|object|string|null = null
$which : string|null = null

IP protocol: 'ipv4' or 'ipv6'

Return values
bool

valid_json()

Valid JSON

public valid_json([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

valid_url()

Checks a string to ensure it is (loosely) a URL.

public valid_url([array<string|int, mixed>|bool|float|int|object|string|null $str = null ]) : bool

Warning: this rule will pass basic strings like "banana"; use valid_url_strict for a stricter rule.

Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
Return values
bool

valid_url_strict()

Checks a URL to ensure it's formed correctly.

public valid_url_strict([array<string|int, mixed>|bool|float|int|object|string|null $str = null ][, string|null $validSchemes = null ]) : bool
Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null = null
$validSchemes : string|null = null

comma separated list of allowed schemes

Return values
bool

        
On this page

Search results