diff --git a/classes/AdminController.php b/classes/AdminController.php index 3f8c770ee..060dc9a63 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -1684,7 +1684,7 @@ class AdminControllerCore extends Controller /* Checking for fields validity */ foreach ($rules['validate'] as $field => $function) if (($value = Tools::getValue($field)) !== false && ($field != 'passwd')) - if (!Validate::$function($value)) + if (!Validate::$function($value) && !empty($value)) $this->_errors[] = $this->l('the field'). ' '.call_user_func(array($class_name, 'displayFieldName'), $field, $class_name).' '. $this->l('is invalid'); diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 8ed4d85df..1e26508ad 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -564,7 +564,7 @@ abstract class ObjectModelCore // Hack for postcode required for country which does not have postcodes if ($value = Tools::getValue($field, $this->{$field}) OR ($field == 'postcode' AND $value == '0')) { - if (!Validate::$function($value)) + if (!Validate::$function($value) && (!empty($value) || in_array($field, $this->fieldsRequired))) $errors[] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.'); else {