Skip to content

Commit

Permalink
Apply NotBlank only to the whole array
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN committed Dec 9, 2018
1 parent 558b149 commit 682ca1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 4 additions & 7 deletions Controller/Annotations/AbstractScalarParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ 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 @@ -69,9 +65,10 @@ public function getConstraints()
if (false === $this->nullable) {
$constraints[] = new NotNull();
}
if (false === $this->allowBlank) {
$constraints[] = new NotBlank();
}
}

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

return $constraints;
Expand Down
1 change: 0 additions & 1 deletion Tests/Controller/Annotations/AbstractScalarParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public function testArrayWithBlankConstraintsWhenParamIsAnArray()
$this->param->allowBlank = false;
$this->assertEquals(array(new Constraints\All(array(
new Constraints\NotNull(),
new Constraints\NotBlank(),
)), new Constraints\NotNull(), new Constraints\NotBlank()), $this->param->getConstraints());
}

Expand Down

0 comments on commit 682ca1a

Please sign in to comment.