Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN committed Dec 15, 2018
1 parent 682ca1a commit 193161d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Controller/Annotations/AbstractScalarParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -67,10 +71,6 @@ public function getConstraints()
}
}

if (false === $this->allowBlank) {
$constraints[] = new NotBlank();
}

return $constraints;
}
}
3 changes: 2 additions & 1 deletion Tests/Controller/Annotations/AbstractScalarParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 193161d

Please sign in to comment.