diff options
| author | Antonio Gallo <tonicucoz@gmail.com> | 2014-09-16 08:03:29 +0000 | 
|---|---|---|
| committer | Antonio Gallo <tonicucoz@gmail.com> | 2014-09-16 08:03:29 +0000 | 
| commit | 11972639df8315753123ebccdadee1f596807ad0 (patch) | |
| tree | 7c932d7e2f0d66afa55e603960f86cef7b00c5ff /h-source/Library/Array/Validate/Strong.php | |
| parent | 6209923d6cfb2418ee926cccdc62a9383e14bd97 (diff) | |
Integrated new EasyGiant Library
Diffstat (limited to 'h-source/Library/Array/Validate/Strong.php')
| -rw-r--r-- | h-source/Library/Array/Validate/Strong.php | 91 | 
1 files changed, 61 insertions, 30 deletions
diff --git a/h-source/Library/Array/Validate/Strong.php b/h-source/Library/Array/Validate/Strong.php index d105319..d907d1d 100644 --- a/h-source/Library/Array/Validate/Strong.php +++ b/h-source/Library/Array/Validate/Strong.php @@ -1,46 +1,38 @@  <?php -// All EasyGiant code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +// EasyGiant is a PHP framework for creating and managing dynamic content +// +// Copyright (C) 2009 - 2014  Antonio Gallo (info@laboratoriolibero.com)  // See COPYRIGHT.txt and LICENSE.txt. +// +// This file is part of EasyGiant +// +// EasyGiant is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// EasyGiant is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with EasyGiant.  If not, see <http://www.gnu.org/licenses/>.  if (!defined('EG')) die('Direct access not allowed!'); -//class to manage arrays +//class to validate associative arrays  class Array_Validate_Strong extends Array_Validate_Base  {  -	public function __construct($lang = 'Eng') +	public function __construct($lang = 'En')  	{  		parent::__construct($lang); +		 +		$this->strength = "strong";  	} - -	public function checkNotEmpty($associativeArray,$keyString) -	{ -		$errorString = null; -		$keyArray = explode(',',$keyString); -		$numb = 0; -		for ($i = 0; $i < count($keyArray); $i++) -		{ -			if (array_key_exists($keyArray[$i],$associativeArray)) -			{ -				if (strcmp(trim($associativeArray[$keyArray[$i]]),'') === 0) -				{ -					$errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]); -					$numb++; -				} -			} -			else -			{ -				$errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]); -				$numb++; -			} -		} -		$this->errorString = $errorString; -		$this->errorNumb = $numb; -		return $numb === 0 ? true : false; -	} -	  	//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are not '' and are equal (===) to each other  	public function checkEqual($associativeArray,$keyString)  	{ @@ -110,6 +102,19 @@ class Array_Validate_Strong extends Array_Validate_Base  	} +	//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are an ISO date. +	public function checkIsoDate($associativeArray,$keyString,$strength = 'strong') +	{ +		if ($this->checkNotEmpty($associativeArray,$keyString)) +		{ +			 +			return parent::checkIsoDate($associativeArray,$keyString,'strong'); +			 +		} else { +			return false; +		} +	} +	  	//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) is a number (integer or number). It makes use of the is_numeric PHP built-in function  	public function checkNumeric($associativeArray,$keyString,$strength = 'strong')  	{ @@ -123,6 +128,18 @@ class Array_Validate_Strong extends Array_Validate_Base  		}  	} +	//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) is an integer string. +	public function checkInteger($associativeArray,$keyString,$strength = 'strong') +	{ +		if ($this->checkNotEmpty($associativeArray,$keyString)) +		{ +			 +			return parent::checkInteger($associativeArray,$keyString,'strong'); +			 +		} else { +			return false; +		} +	}  	//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) have a number of chars smaller than $maxLenght  	public function checkLength($associativeArray,$keyString,$maxLength = 10) @@ -177,4 +194,18 @@ class Array_Validate_Strong extends Array_Validate_Base  			return false;  		}  	} +	 +	//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are decimal with the format indicated in $format +	//$format: M,D M is the maximum number of digits, D is the number of digits to the right of the decimal point +	public function checkDecimal($associativeArray,$keyString,$format = '10,2') +	{ +		if ($this->checkNotEmpty($associativeArray,$keyString)) +		{ +			 +			return parent::checkDecimal($associativeArray,$keyString,$format); +			 +		} else { +			return false; +		} +	}  }  | 
