From 11972639df8315753123ebccdadee1f596807ad0 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Tue, 16 Sep 2014 08:03:29 +0000 Subject: Integrated new EasyGiant Library --- h-source/Library/Array/Validate/Strong.php | 91 ++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 30 deletions(-) (limited to 'h-source/Library/Array/Validate/Strong.php') 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 @@ . 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; + } + } } -- cgit v1.2.3