[*] 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:
@@ -97,7 +97,7 @@ class CartRuleCore extends ObjectModel
|
||||
'product_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'shop_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'free_shipping' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPercentage'),
|
||||
'reduction_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'reduction_tax' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'reduction_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
|
||||
@@ -64,7 +64,7 @@ class ReferrerCore extends ObjectModel
|
||||
'http_referer_like_not' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'),
|
||||
'request_uri_like_not' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'),
|
||||
'base_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'percent_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'percent_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPercentage'),
|
||||
'click_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
),
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class RiskCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isString', 'required' => true, 'size' => 20),
|
||||
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor', 'size' => 32),
|
||||
'percent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt')
|
||||
'percent' => array('type' => self::TYPE_INT, 'validate' => 'isPercentage')
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
+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