Q_Valid Class
Functions for validating stuff
Item Index
Methods
date
-
$date_string
Determines whether a string represents a valid date You might want to use checkdate after this, to validate this date against the Gregorian calendar.
Parameters:
-
$date_string
StringThe string to test
Returns:
Returns false if can't be parsed. Otherwise, an associative array.
domain
-
[$options=array()]
Checks for a valid domain
Parameters:
-
[$options=array()]
Array optionalAn array that can contain the following keys:
- "checkMX" => if true, will check mx records
- "allowIP" => if true, allows IP addresses
Returns:
email
-
$address
-
[$normalized_address=null]
-
[$options=array()]
Checks for a valid email address
Parameters:
-
$address
StringThe email address to test
-
[$normalized_address=null]
&string optionalWill be filled with the string representing the normalized email address
-
[$options=array()]
Array optionalAn array that can contain the following keys:
- "check_mx" => if true, will check mx records
- "allowIP" => if true, accepts IP addresses after the @
Returns:
Whether the email address seems valid
getmxrr
-
$hostname
-
$mxhosts
Parameters:
-
$hostname
String -
$mxhosts
&array
Returns:
nonce
-
[$throwIfInvalid=false]
-
[$missingIsValid=false]
Use this for validating the nonce
Parameters:
-
[$throwIfInvalid=false]
Boolean optionalIf true, throws an exception if the nonce is invalid.
-
[$missingIsValid=false]
Boolean optionalIf true, returns true if request body is missing nonce.
phone
-
$number
-
[$normalized_number=null]
Checks for a valid phone number
Parameters:
-
$number
StringThe phone number to test
-
[$normalized_number=null]
&string optionalWill be filled with the string representing the normalized phone number
Returns:
Whether the phone number seems like it could be valid
requireFields
-
$fields
-
[$source=$_REQUEST]
-
[$throwIfMissing=false]
Convenience method to require certain fields to be present in an array, and generate errors otherwise.
Parameters:
-
$fields
ArrayArray of strings or nested arrays of strings, naming fields that are required
-
[$source=$_REQUEST]
Array optionalWhere to look for the fields
-
[$throwIfMissing=false]
Boolean optionalWhether to throw an exception on the first violation, or add them to a list.
Returns:
The resulting list of exceptions
signature
-
[$throwIfInvalid=false]
-
[$data=$_REQUEST]
-
[$fieldKeys]
Validates the signature of the request (from Q_Request::special('sig', null))
Parameters:
-
[$throwIfInvalid=false]
Boolean optionalIf true, throws an exception if the nonce is invalid.
-
[$data=$_REQUEST]
Array optionalThe data to check the signature of
-
[$fieldKeys]
Array | String optionalPath of the key under which to save signature
Returns:
Whether the phone number seems like it could be valid
url
-
$url
-
[$check_domain=false]
-
[$fixed_url=null]
Says whether the first parameter is an absolute URL or not.
Parameters:
-
$url
StringThe string to test.
-
[$check_domain=false]
String optionalWhether to check the domain, too
-
[$fixed_url=null]
&string optional
Returns:
writeable
-
$path
Checks both files and folders for writability
Parameters:
-
$path
String