[*] 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:
+13
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user