diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php
index 1810ad117..6d455d49d 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php
@@ -237,7 +237,15 @@ class TheliaLoop implements SmartyPluginInterface {
continue;
}
- /* check default */
+ /* check type */
+ if($value !== null && !$argument->type->isValid($value)) {
+ $faultActor[] = $argument->name;
+ $faultDetails[] = sprintf('Invalid value for "%s" argument', $argument->name);
+ continue;
+ }
+
+ /* set default */
+ /* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
if($value === null) {
$value = $argument->default;
}
diff --git a/core/lib/Thelia/Type/TypeCollection.php b/core/lib/Thelia/Type/TypeCollection.php
index 621197776..ebbd3274b 100755
--- a/core/lib/Thelia/Type/TypeCollection.php
+++ b/core/lib/Thelia/Type/TypeCollection.php
@@ -65,7 +65,7 @@ class TypeCollection implements \Iterator
* (PHP 5 >= 5.0.0)
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
- * @return \Thelia\Core\Template\Element\LoopResultRow
+ * @return \Thelia\Type\TypeInterface
*/
public function current()
{
@@ -116,4 +116,25 @@ class TypeCollection implements \Iterator
{
$this->position = 0;
}
+
+ /**
+ * @param $value
+ *
+ * @return bool
+ */
+ public function isValid($value)
+ {
+ $this->rewind();
+ while ($this->valid()) {
+ $type = $this->current();
+
+ if($type->isValid($value)) {
+ return true;
+ }
+
+ $this->next();
+ }
+
+ return false;
+ }
}
diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html
index f93dd3876..7bba1e5da 100755
--- a/templates/smarty-sample/index.html
+++ b/templates/smarty-sample/index.html
@@ -1,80 +1,5 @@
-{include file="includes/header.html"}
-
Category loop example
-Conditional example #1
- - {ifloop rel="catloop2"} - Hey ! Loop catloop2 is not empty: -Loop catloop2 is empty
- {/elseloop} -Conditional example #2
- - {ifloop rel="catloop3"} - Loop catloop3 is not empty: -Loop catloop3 is empty
- {/elseloop} - - {elseloop rel="catloop2"} -... but catloop2 is still empty :-)
- {/elseloop} - {ifloop rel="catloop1"} -... and catloop1 is still NOT empty :-)
- {/ifloop} -Traditional for loop
- {for $index=5 to 12 step 1} - Compteur = {$index}