Class with static functions for PARAMETER VALIDATION (for example, for site security)
DEPENDENCIES: None
USAGE EXAMPLE:
parameterValidation::validateInteger($myValue)
public static function validatePositiveInteger($arg)
/* Check if the given argument is a positive, non-zero integer, (or a string representing such an integer.)
Return true if the check succeeded, or false if not
*/
public static function validateInteger($arg)
/* Check if the given argument is a positive integer (or a string representing such an integer.)
Return true if the check succeeded, or false if not
*/
public static function validateNumeric($arg)
/* Check if the given argument is a numeric quantity.
Return true if the check succeeded, or false if not
*/
public static function validateAlphanumeric($arg)
/* Verify that the given argument is alphanumeric
*/
public static function validateAlphanumericOrBlank($arg)
/* Verify that the given argument is alphanumeric or blank
*/
public static function validateAlphanumericOrUnderscore($arg)
/* Verify that the given argument is alphanumeric or underscore
*/
public static function validateUsername($user)
/* Verify that the given username (which might also be an email address or an ID) is drawn from the allowed character set
*/
public static function validatePassword($pass)
/* Verify that the given password is drawn from the allowed character set
*/
public static function validatePattern($string, $pattern, $debug = false)
/* Check the given string value against the specified RegEx pattern.
If it matches (or if it's an empty string), return true; otherwise print out the given error message (details based on the $stage flag) and return false.
EXAMPLE: validatePattern($ID, "/^[0-9]+$/", "ID must be an integer. Value provided: “$ID”", true);
*/