diff --git a/Controller/Annotations/AbstractScalarParam.php b/Controller/Annotations/AbstractScalarParam.php index 21f05254d..dd67c1741 100644 --- a/Controller/Annotations/AbstractScalarParam.php +++ b/Controller/Annotations/AbstractScalarParam.php @@ -56,6 +56,10 @@ public function getConstraints() )); } + if (false === $this->allowBlank) { + $constraints[] = new NotBlank(); + } + // If the user wants to map the value, apply all constraints to every // value of the map if ($this->map) { @@ -67,10 +71,6 @@ public function getConstraints() } } - if (false === $this->allowBlank) { - $constraints[] = new NotBlank(); - } - return $constraints; } } diff --git a/Tests/Controller/Annotations/AbstractScalarParamTest.php b/Tests/Controller/Annotations/AbstractScalarParamTest.php index 8f5cc71b4..a8499ab73 100644 --- a/Tests/Controller/Annotations/AbstractScalarParamTest.php +++ b/Tests/Controller/Annotations/AbstractScalarParamTest.php @@ -106,7 +106,8 @@ public function testArrayWithBlankConstraintsWhenParamIsAnArray() $this->param->allowBlank = false; $this->assertEquals(array(new Constraints\All(array( new Constraints\NotNull(), - )), new Constraints\NotNull(), new Constraints\NotBlank()), $this->param->getConstraints()); + new Constraints\NotBlank(), + )), new Constraints\NotNull()), $this->param->getConstraints()); } public function testArrayWithNoConstraintsDoesNotCreateInvalidConstraint()