FormatRules
in package
Format validation Rules.
Tags
Table of Contents
Methods
- 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.
Methods
alpha()
Alpha
public
alpha([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolalpha_dash()
Alphanumeric with underscores and dashes
public
alpha_dash([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Tags
Return values
boolalpha_numeric()
Alphanumeric
public
alpha_numeric([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolalpha_numeric_punct()
Alphanumeric, spaces, and a limited set of punctuation characters.
public
alpha_numeric_punct(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 : string|null
Tags
Return values
boolalpha_numeric_space()
Alphanumeric w/ spaces
public
alpha_numeric_space([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolalpha_space()
Alpha with spaces.
public
alpha_space([string|null $value = null ]) : bool
Parameters
- $value : string|null = null
-
Value.
Return values
bool —True if alpha with spaces, else false.
decimal()
Decimal number
public
decimal([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolhex()
String of hexidecimal characters
public
hex([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolinteger()
Integer
public
integer([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolis_natural()
Is a Natural number (0,1,2,3, etc.)
public
is_natural([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolis_natural_no_zero()
Is a Natural number, but not a zero (1,2,3, etc.)
public
is_natural_no_zero([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolnumeric()
Numeric
public
numeric([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolregex_match()
Compares value against a regular expression pattern.
public
regex_match(string|null $str, string $pattern) : bool
Parameters
- $str : string|null
- $pattern : string
Return values
boolstring()
Any type of string
public
string([string|null $str = null ]) : bool
Note: we specifically do NOT type hint $str here so that it doesn't convert numbers into strings.
Parameters
- $str : string|null = null
Return values
booltimezone()
Validates that the string is a valid timezone as per the timezone_identifiers_list function.
public
timezone([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Tags
Return values
boolvalid_base64()
Valid Base64
public
valid_base64([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 : string|null = null
Return values
boolvalid_date()
Checks for a valid date and matches a given date format
public
valid_date([string|null $str = null ][, non-empty-string|null $format = null ]) : bool
Parameters
- $str : string|null = null
- $format : non-empty-string|null = null
Return values
boolvalid_email()
Checks for a correctly formatted email address
public
valid_email([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolvalid_emails()
Validate a comma-separated list of email addresses.
public
valid_emails([string|null $str = null ]) : bool
Example: valid_emails[one@example.com,two@example.com]
Parameters
- $str : string|null = null
Return values
boolvalid_ip()
Validate an IP address (human readable format or binary string - inet_pton)
public
valid_ip([string|null $ip = null ][, string|null $which = null ]) : bool
Parameters
- $ip : string|null = null
- $which : string|null = null
-
IP protocol: 'ipv4' or 'ipv6'
Return values
boolvalid_json()
Valid JSON
public
valid_json([string|null $str = null ]) : bool
Parameters
- $str : string|null = null
Return values
boolvalid_url()
Checks a string to ensure it is (loosely) a URL.
public
valid_url([string|null $str = null ]) : bool
Warning: this rule will pass basic strings like "banana"; use valid_url_strict for a stricter rule.
Parameters
- $str : string|null = null
Return values
boolvalid_url_strict()
Checks a URL to ensure it's formed correctly.
public
valid_url_strict([string|null $str = null ][, string|null $validSchemes = null ]) : bool
Parameters
- $str : string|null = null
- $validSchemes : string|null = null
-
comma separated list of allowed schemes