Phpfox_Validator

Description

Validatior Used for site wide validation of POST forms. Includes the feature to validate forms using JavaScript and PHP as a failsafe.

  • author: Raymond Benc
  • version: $Id: validator.class.php 1687 2010-07-22 03:13:27Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/validator/validator.class.php (line 18)


	
			
Variable Summary
 array $aErrors
 string $sFormName
 array $_aDefaults
 array $_aRegex
 bool $_bParent
 string $_sName
Method Summary
 Phpfox_Validator __construct ()
 bool check (string $sString, [array $aParams = array()])
 string createJS ()
 string getJsForm ([bool $bReturn = true])
 boolean isValid (array $aVal)
 mixed process (array $aParams, array $aValues)
 object Return set (array $aParams)
 bool verify (string $sPattern, string $sValue)
 mixed _checkRoutine (array $aFieldValue, string $sFieldKey, [string $sType = 'php'], [string $sValue = ''])
 string _createIfJS (string $sIfStatment, string $sTitle, [string $sFieldKey = ''], [string $sInfoGuide = ''])
Variables
array $aErrors = array() (line 25)

List of all the errors.

  • access: private
string $sFormName (line 32)

Name of the curremt HTML form.

  • access: private
array $_aDefaults (line 46)

List of default regex rules.

  • access: private
array $_aRegex = array(
'user_name' => '/^[a-zA-Z0-9_\- ]{5,25}$/',
'email' => '/^[0-9a-zA-Z]([\-.\w]*[0-9a-zA-Z]?)*@([0-9a-zA-Z][\-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,}$/',
'html' => '/<(.*?)>/',
'url' => '~(?>[a-z+]{2,}://|www\.)(?:[a-z0-9]+(?:\.[a-z0-9]+)?@)?(?:(?:[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])(?:\.[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])+|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?:/[^\\/:?*"<>|\n]*[a-z0-9])*/?(?:\?[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?(?:&[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?)*)?(?:#[a-z0-9_%.]+)?~is',
'currency_id' => '/^[A-Z]{3,3}$/'
)
(line 60)

Default regex rules.

  • access: private
bool $_bParent = false (line 53)

Check to see if we should load a parent check.

  • access: private
string $_sName (line 39)

Name of the validation.

  • access: private
Methods
Constructor __construct (line 73)

Class constructor used to load default validator rules.

Found in the file: include/setting/validator.sett.php

  • access: public
Phpfox_Validator __construct ()
check (line 112)

Check a string value against multiple regex checks.

  • return: FALSE if string failed, TRUE if string passed.
  • access: public
bool check (string $sString, [array $aParams = array()])
  • string $sString: Value to check.
  • array $aParams: ARRAY of regex checks to perform.
createJS (line 514)

Client side check

  • return: Javascript data needed for a specific form
  • access: public
string createJS ()
getJsForm (line 488)

Create the JS form onsubmit=""

  • return: Call to JS function
  • access: public
string getJsForm ([bool $bReturn = true])
  • bool $bReturn: TRUE to include the "return" in the JavaScript code.
isValid (line 499)

Server Side check

  • return: Check if everything is valid or not
  • access: public
boolean isValid (array $aVal)
  • array $aVal: holds all the post arrays
process (line 138)

Process a form and perform regex checks on all the values.

  • return: Returns all the values cleaned if everything is okay, however if something failed a regex check we return FALSE.
  • access: public
mixed process (array $aParams, array $aValues)
  • array $aParams: ARRAY of regex checks.
  • array $aValues: ARRAY of form values.
set (line 468)

Build a form validation check.

  • return: self.
  • access: public
object Return set (array $aParams)
  • array $aParams: ARRAY of settings.
verify (line 90)

Verify a regex pattern against a string value.

  • return: TRUE if string passed, FALSE if string failed; comes with error message.
  • access: public
bool verify (string $sPattern, string $sValue)
  • string $sPattern: Regex pattern to check.
  • string $sValue: String value.
_checkRoutine (line 544)

Method is used to check if POST data fields is valid for either PHP or Javascript.

  • return: PHP returns bool|JS returns JS layout
  • access: private
mixed _checkRoutine (array $aFieldValue, string $sFieldKey, [string $sType = 'php'], [string $sValue = ''])
  • array $aFieldValue: is the array of field values
  • string $sFieldKey: is the KEY or form ID
  • string $sType: is the type of form
  • string $sValue: is the value, only for PHP
_createIfJS (line 716)

Creates a JS IF statment

  • return: JS Content returned
  • access: private
string _createIfJS (string $sIfStatment, string $sTitle, [string $sFieldKey = ''], [string $sInfoGuide = ''])
  • string $sIfStatment: is the JS IF statment will plan to execute
  • string $sTitle: is the error message if the check has failed
  • string $sFieldKey: Field ID/Class if using a parent check.
  • string $sInfoGuide: Info guide to explain the error in more detail.

Documentation generated on Tue, 28 Sep 2010 10:36:45 +0200 by phpDocumentor 1.4.0a2