[ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 //-------------------------------------------------------------------------------- 3 // Copyright 2003 Procata, Inc. 4 // Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) 5 //-------------------------------------------------------------------------------- 6 /** 7 * @package WACT_VALIDATION 8 * @version $Id: validator.inc.php,v 1.29 2004/11/16 01:55:37 jeffmoore Exp $ 9 */ 10 //-------------------------------------------------------------------------------- 11 12 /** 13 * Performs the validation checks against the Rules 14 * @see http://wact.sourceforge.net/index.php/Validator 15 * @see http://wact.sourceforge.net/index.php/Rule 16 * @access public 17 * @package WACT_VALIDATION 18 */ 19 class Validator { 20 /** 21 * Indexed array of Rule objects 22 * @see Rule 23 * @var array 24 * @access private 25 */ 26 var $rules = array(); 27 /** 28 * Instance of ErrorList 29 * @see ErrorList 30 * @var ErrorList 31 * @access private 32 */ 33 var $ErrorList; 34 /** 35 * Whether the validation process was valid 36 * @var boolean 37 * @access private 38 */ 39 var $IsValid = TRUE; 40 41 /** 42 * Initalize Error List 43 * @param Rule 44 * @return void 45 * @access protected 46 */ 47 function &createErrorList() { 48 require_once WACT_ROOT . 'validation/errorlist.inc.php'; 49 return new ErrorList(); 50 } 51 52 /** 53 * Registers a Rule 54 * @param Rule 55 * @return void 56 * @access public 57 */ 58 function addRule(&$Rule) { 59 $this->rules[] = $Rule; 60 } 61 62 /** 63 * Returns the ErrorList 64 * @return ErrorList 65 * @access public 66 */ 67 function &getErrorList() { 68 return $this->ErrorList; 69 } 70 71 /** 72 * Whether the validation process was valid 73 * @param string fieldname (default=NULL) unused 74 * @return boolean TRUE if valid 75 * @access public 76 */ 77 function IsValid($FieldName = NULL) { 78 return $this->IsValid; 79 } 80 81 /** 82 * Perform the validation 83 * @param DataSpace subclass of DataSpace to validate 84 * @return void 85 * @access public 86 */ 87 function validate(&$DataSource) { 88 $ErrorList =& $this->createErrorList(); 89 foreach( array_keys($this->rules) as $key) { 90 if (! $this->rules[$key]->validate($DataSource, $ErrorList)) { 91 $this->IsValid = FALSE; 92 } 93 } 94 95 $this->ErrorList =& $ErrorList; 96 } 97 } 98 99 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 28 19:36:09 2004 | Cross-referenced by PHPXref 0.5 |