Show:

Q_Valid Class

Module: Q

Functions for validating stuff

Item Index

Methods

Methods

date

(
  • $date_string
)
Boolean | Array static

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 String

    The string to test

Returns:

Boolean | Array:

Returns false if can't be parsed. Otherwise, an associative array.

domain

(
  • [$options=array()]
)
Boolean static

Checks for a valid domain

Parameters:

  • [$options=array()] Array optional

    An array that can contain the following keys:

    • "checkMX" => if true, will check mx records
    • "allowIP" => if true, allows IP addresses

Returns:

Boolean:

email

(
  • $address
  • [$normalized_address=null]
  • [$options=array()]
)
Boolean static

Checks for a valid email address

Parameters:

  • $address String

    The email address to test

  • [$normalized_address=null] &string optional

    Will be filled with the string representing the normalized email address

  • [$options=array()] Array optional

    An array that can contain the following keys:

    • "check_mx" => if true, will check mx records
    • "allowIP" => if true, accepts IP addresses after the @

Returns:

Boolean:

Whether the email address seems valid

getmxrr

(
  • $hostname
  • $mxhosts
)
Boolean private static

Parameters:

  • $hostname String
  • $mxhosts &array

Returns:

Boolean:

nonce

(
  • [$throwIfInvalid=false]
  • [$missingIsValid=false]
)
static

Use this for validating the nonce

Parameters:

  • [$throwIfInvalid=false] Boolean optional

    If true, throws an exception if the nonce is invalid.

  • [$missingIsValid=false] Boolean optional

    If true, returns true if request body is missing nonce.

phone

(
  • $number
  • [$normalized_number=null]
)
Boolean static

Checks for a valid phone number

Parameters:

  • $number String

    The phone number to test

  • [$normalized_number=null] &string optional

    Will be filled with the string representing the normalized phone number

Returns:

Boolean:

Whether the phone number seems like it could be valid

requireFields

(
  • $fields
  • [$source=$_REQUEST]
  • [$throwIfMissing=false]
)
Array static

Convenience method to require certain fields to be present in an array, and generate errors otherwise.

Parameters:

  • $fields Array

    Array of strings or nested arrays of strings, naming fields that are required

  • [$source=$_REQUEST] Array optional

    Where to look for the fields

  • [$throwIfMissing=false] Boolean optional

    Whether to throw an exception on the first violation, or add them to a list.

Returns:

Array:

The resulting list of exceptions

signature

(
  • [$throwIfInvalid=false]
  • [$data=$_REQUEST]
  • [$fieldKeys]
)
Boolean static

Validates the signature of the request (from Q_Request::special('sig', null))

Parameters:

  • [$throwIfInvalid=false] Boolean optional

    If true, throws an exception if the nonce is invalid.

  • [$data=$_REQUEST] Array optional

    The data to check the signature of

  • [$fieldKeys] Array | String optional

    Path of the key under which to save signature

Returns:

Boolean:

Whether the phone number seems like it could be valid

url

(
  • $url
  • [$check_domain=false]
  • [$fixed_url=null]
)
Boolean static

Says whether the first parameter is an absolute URL or not.

Parameters:

  • $url String

    The string to test.

  • [$check_domain=false] String optional

    Whether to check the domain, too

  • [$fixed_url=null] &string optional

Returns:

Boolean:

writeable

(
  • $path
)
Boolean static

Checks both files and folders for writability

Parameters:

  • $path String

Returns:

Boolean: