Skip to content

Commit da8d1ff

Browse files
author
Mathias STRASSER
committed
Add NotBlank constraint on map
1 parent 79cb3a1 commit da8d1ff

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Controller/Annotations/AbstractScalarParam.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public function getConstraints()
6767
if (false === $this->nullable) {
6868
$constraints[] = new NotNull();
6969
}
70+
if (false === $this->allowBlank) {
71+
$constraints[] = new NotBlank();
72+
}
7073
}
7174

7275
return $constraints;

Tests/Controller/Annotations/AbstractScalarParamTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public function testConstraintsTransformWhenParamIsAnArray()
9999
)), new Constraints\NotNull()), $this->param->getConstraints());
100100
}
101101

102+
public function testArrayWithBlankConstraintsWhenParamIsAnArray()
103+
{
104+
$this->param->map = true;
105+
$this->param->allowBlank = false;
106+
$this->assertEquals(array(new Constraints\All(array(
107+
new Constraints\NotNull(),
108+
new Constraints\NotBlank(),
109+
)), new Constraints\NotNull(), new Constraints\NotBlank()), $this->param->getConstraints());
110+
}
111+
102112
public function testArrayWithNoConstraintsDoesNotCreateInvalidConstraint()
103113
{
104114
$this->param->nullable = true;

0 commit comments

Comments
 (0)