Class Validation

Description

Data validation class helper

Located in /class.validation.php (line 22)


                
			
Method Summary
static void Clear ()
static boolean FieldHasErrors (string $sField)
static array GetErrors ()
static boolean HasErrors ()
static void SetError (string $sKey, string $sError)
static void ValidateAlpha ( $sName,  $sValue, [ $sMessage = ""])
static void ValidateAlphaNumeric ( $sName,  $sValue, [ $sMessage = ""])
static boolean ValidateAmericanExpress (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static boolean ValidateByMatch (string $sName, string $sValue, string $sExpr, string $sMessage)
static boolean ValidateDate (string $sName, string $sValue, [string $sMessage = ""])
static boolean ValidateDateGreaterThan (string $sName, string $sDate, string $sMatch, [ $sMessage = ""], string $sMessages)
static boolean ValidateDiscover (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static boolean ValidateDomain (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static void ValidateEmail ( $sName,  $sValue, [ $sMessage = ""])
static boolean ValidateEqualTo (string $sName, string $sValue, string $sMatchValue, [string $sMessage = ""])
static boolean ValidateFileMaxSize (string $sName, integer $iSizeInBytes, [string $sMessage = ""])
static boolean ValidateFileMimeType (string $sName, string $sTmpFileName, array $aMimeTypes, [string $sMessage = ""])
static boolean ValidateFilePresent (string $sName, [string $sMessage = ""])
static boolean ValidateInteger (string $sName, string $sValue, [string $sMessage = ""])
static boolean ValidateLengthRange (string $sName, string $sValue, integer $fMin, integer $fMax, [string $sMessage = ""])
static boolean ValidateLuhnNumber (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static boolean ValidateMasterCard (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static boolean ValidateMaxLength (string $sName, string $sValue, integer $iMax, [string $sMessage = ""])
static boolean ValidateMinLength (string $sName, string $sValue, integer $iMin, [string $sMessage = ""])
static boolean ValidateNumeric (string $sName, string $sValue, [string $sMessage = ""])
static boolean ValidatePresent (string $sName, string $sValue, [string $sMessage = ""])
static boolean ValidateTime (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static boolean ValidateVisa (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
static void ValidateZipCode ( $sName,  $sValue, [ $sMessage = ""])
Methods
static method Clear (line 106)

Clears any errors in the error list

  • access: public
static void Clear ()
static method FieldHasErrors (line 55)

Returns whether or not the specified field has any errors noted through validation calls

  • return: Returns true if there are any errors stored in the error list for the specified field, or false otherwise
  • access: public
static boolean FieldHasErrors (string $sField)
  • string $sField: The name of the field to check for errors on
static method GetErrors (line 80)

Returns the list of errors generated through validation calls. Returns in the format of:

 Array(
     field1 => array(
         0 => "field1 must be between 2 and 32 characters",
         1 => "field1 is not between valid email address"
     ),
     field2 => array(
         0 => "field2 is required"
     )
 )

  • return: An array of error messages generated by validation calls. This array contains a set of arrays for each element name provided to validation calls.
  • access: public
static array GetErrors ()
static method HasErrors (line 41)

Returns whether or not any errors were noted through validation calls

  • return: Returns true if there are any errors stored in the error list, or false otherwise
  • access: public
static boolean HasErrors ()
static method SetError (line 94)

Stores the supplied error in the static error list

  • access: public
static void SetError (string $sKey, string $sError)
  • string $sKey: The name of the form field the error occurred on
  • string $sError: The error message
static method ValidateAlpha (line 346)
  • access: public
static void ValidateAlpha ( $sName,  $sValue, [ $sMessage = ""])
  • $sName
  • $sValue
  • $sMessage
static method ValidateAlphaNumeric (line 375)
  • access: public
static void ValidateAlphaNumeric ( $sName,  $sValue, [ $sMessage = ""])
  • $sName
  • $sValue
  • $sMessage
static method ValidateAmericanExpress (line 998)

Validates that the supplied data is a valid American Express credit card number.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateAmericanExpress (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateByMatch (line 610)

Validates that a supplied value matches the supplied regular expression. If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateByMatch (string $sName, string $sValue, string $sExpr, string $sMessage)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sExpr: The regular expression to match against the supplied data
  • string $sMessage: The message to store in the list of validation errors if validation fails
static method ValidateDate (line 639)

Validates that the supplied date is a validate date. Date can be in the following formats:

MM/DD/YYYY MM-DD-YYYY YYYYMMDD

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateDate (string $sName, string $sValue, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails. Default: ""
static method ValidateDateGreaterThan (line 711)

First validates that sValue and sMatch are validate dates using the ValidateDate() method. If these checks pass, this method then validates that sMatch is greater than sValue.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateDateGreaterThan (string $sName, string $sDate, string $sMatch, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sDate: The data to validate against
  • string $sMatch: The date to compare against
  • string $sMessages: The message to store in the list of validation errors if validation fails
  • $sMessage
static method ValidateDiscover (line 966)

Validates that the supplied data is a valid Discover credit card number.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateDiscover (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateDomain (line 811)

Validates that the supplied value is a valid domain name.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateDomain (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateEmail (line 405)
  • access: public
static void ValidateEmail ( $sName,  $sValue, [ $sMessage = ""])
  • $sName
  • $sValue
  • $sMessage
static method ValidateEqualTo (line 155)

Validates that the two supplied values are equal. This method is case insensistive, and also compares the trimmed values. If validation fails, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateEqualTo (string $sName, string $sValue, string $sMatchValue, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The value of the field being validated
  • string $sMatchValue: The value of the field being compared
  • string $sMessage: Optional, the message to store in the list of validation errors if validation fails
static method ValidateFileMaxSize (line 577)

Validates that the size of an uploaded file does not exceed a certain file size. If validation fails, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateFileMaxSize (string $sName, integer $iSizeInBytes, [string $sMessage = ""])
  • string $sName: The name of the file field to validate
  • integer $iSizeInBytes: The maximum size the file is allowed to be
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails. Default: ""
static method ValidateFileMimeType (line 543)

Validates that an uploaded file is one of the supplied mime types. If FileInfo extension is not installed, this method relies on the mime type sent by the browser, and this type cannot be trusted, or may not even be present. OpenAvanti recommends installing FileInfo.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateFileMimeType (string $sName, string $sTmpFileName, array $aMimeTypes, [string $sMessage = ""])
  • string $sName: The name of the file field to validate
  • string $sTmpFileName: The name of the uploaded temporary file
  • array $aMimeTypes: An array of file extensions that are valid for the uploaded file
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails. Default: ""
static method ValidateFilePresent (line 511)

Validates that a file was uploaded based on the name of the file field. If validation fails, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateFilePresent (string $sName, [string $sMessage = ""])
  • string $sName: The name of the file field to validate
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails
static method ValidateInteger (line 317)

Validates that the supplied data is a valid integer. If not, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateInteger (string $sName, string $sValue, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails
static method ValidateLengthRange (line 257)

Validates that the supplied value's length is between the supplied minimum and maximum range. This method DOES NOT determine whether the value is in the range, but the number characters in the value is in the supplied range. This method trims the data before validating. If not, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateLengthRange (string $sName, string $sValue, integer $fMin, integer $fMax, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • integer $fMin: The minimum number of characters the supplied data must be in length to pass validation
  • integer $fMax: The maximum number of characters the supplied data must not surpass in length to pass validation
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails. Default: ""
static method ValidateLuhnNumber (line 843)

Validates that the supplied data is a Luhn number

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateLuhnNumber (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateMasterCard (line 932)

Validates that the supplied data is a valid MasterCard credit card number.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateMasterCard (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateMaxLength (line 220)

Validates that the supplied data is not greater than iMax characters in length. This method trims the data before validating. If not, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateMaxLength (string $sName, string $sValue, integer $iMax, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • integer $iMax: The maximum number of characters the supplied data must not surpass in length to pass validation
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails. Default: ""
static method ValidateMinLength (line 186)

Validates that the supplied data is at least iMin characters in length. This method trims the data before validating. If not, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateMinLength (string $sName, string $sValue, integer $iMin, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • integer $iMin: The minimum number of characters the supplied data must be in length to pass validation
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails. Default: ""
static method ValidateNumeric (line 288)

Validates that the supplied data is a valid numeric value. If not, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidateNumeric (string $sName, string $sValue, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessage: Optional; the message to store in the list of validation errors if validation fails
static method ValidatePresent (line 123)

Validates that the supplied value is not empty. If not, an error message is added to the list of errors.

  • return: True if the data passes validation, false otherwise
  • access: public
static boolean ValidatePresent (string $sName, string $sValue, [string $sMessage = ""])
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessage: Optional, the message to store in the list of validation errors if validation fails
static method ValidateTime (line 756)

Validates that the supplied time value is a validate time. This method basically validates that there are two integer values separated by a colon. Seconds and any AM/PM notation are stripped off. The first integer (hours) value must be between 1 and 23, and the second integer value (minutes) must be between 0 and 59.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateTime (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateVisa (line 900)

Validates that the supplied data is a valid Visa credit card number.

If validation fails, an error message is added to the list of errors.

  • return: True if the data passets validation, false otherwise
  • access: public
static boolean ValidateVisa (string $sName, string $sValue, [ $sMessage = ""], string $sMessages)
  • string $sName: The name of the field being validated
  • string $sValue: The data to validate against
  • string $sMessages: Optional; the message to store in the list of validation errors if validation fails. Default: ""
  • $sMessage
static method ValidateZipCode (line 474)
  • access: public
static void ValidateZipCode ( $sName,  $sValue, [ $sMessage = ""])
  • $sName
  • $sValue
  • $sMessage

Documentation generated on Thu, 25 Feb 2010 15:59:42 -0500 by phpDocumentor 1.4.3