[*] BO : added a new Validate method "isPercentage"

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16285 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-07-09 13:05:31 +00:00
parent acc15c9e55
commit c51c83edc0
4 changed files with 16 additions and 5 deletions
+13 -2
View File
@@ -622,7 +622,7 @@ class ValidateCore
/**
* Check for an integer validity
*
* @param integer $id Integer to validate
* @param integer $value Integer to validate
* @return boolean Validity is ok or not
*/
public static function isInt($value)
@@ -633,13 +633,24 @@ class ValidateCore
/**
* Check for an integer validity (unsigned)
*
* @param integer $id Integer to validate
* @param integer $value Integer to validate
* @return boolean Validity is ok or not
*/
public static function isUnsignedInt($value)
{
return (preg_match('#^[0-9]+$#', (string)$value) && $value < 4294967296 && $value >= 0);
}
/**
* Check for an percentage validity (between 0 and 100)
*
* @param float $value Float to validate
* @return boolean Validity is ok or not
*/
public static function isPercentage($value)
{
return (Validate::isFloat($value) && $value >= 0 && $value <= 100);
}
/**
* Check for an integer validity (unsigned)