Skip to content

Commit cda6cba

Browse files
committed
feature symfony#15279 Added {{ value }} message placeholder to UniqueEntityValidator (jperovic)
This PR was submitted for the 2.8 branch but it was merged into the 3.1-dev branch instead (closes symfony#15279). Discussion ---------- Added {{ value }} message placeholder to UniqueEntityValidator | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#15268 | License | MIT | Doc PR | - Apologize if I missed something. This is my first contribution to a large scale project. Commits ------- 9cf1ce9 Added {{ value }} message placeholder to UniqueEntityValidator
2 parents c650b8f + 9cf1ce9 commit cda6cba

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.1.0
5+
-----
6+
7+
* added "{{ value }}" message placeholder to UniqueEntityValidator
8+
49
3.0.0
510
-----
611

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function testValidateUniqueness()
161161

162162
$this->buildViolation('myMessage')
163163
->atPath('property.path.name')
164+
->setParameter('{{ value }}', 'Foo')
164165
->setInvalidValue('Foo')
165166
->assertRaised();
166167
}
@@ -184,6 +185,7 @@ public function testValidateCustomErrorPath()
184185

185186
$this->buildViolation('myMessage')
186187
->atPath('property.path.bar')
188+
->setParameter('{{ value }}', 'Foo')
187189
->setInvalidValue('Foo')
188190
->assertRaised();
189191
}
@@ -235,6 +237,7 @@ public function testValidateUniquenessWithIgnoreNull()
235237

236238
$this->buildViolation('myMessage')
237239
->atPath('property.path.name')
240+
->setParameter('{{ value }}', 'Foo')
238241
->setInvalidValue('Foo')
239242
->assertRaised();
240243
}
@@ -266,6 +269,7 @@ public function testValidateUniquenessWithValidCustomErrorPath()
266269

267270
$this->buildViolation('myMessage')
268271
->atPath('property.path.name2')
272+
->setParameter('{{ value }}', 'Bar')
269273
->setInvalidValue('Bar')
270274
->assertRaised();
271275
}
@@ -398,6 +402,7 @@ public function testAssociatedEntity()
398402

399403
$this->buildViolation('myMessage')
400404
->atPath('property.path.single')
405+
->setParameter('{{ value }}', 1)
401406
->setInvalidValue(1)
402407
->assertRaised();
403408
}

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public function validate($entity, Constraint $constraint)
140140

141141
$this->context->buildViolation($constraint->message)
142142
->atPath($errorPath)
143+
->setParameter('{{ value }}', $invalidValue)
143144
->setInvalidValue($invalidValue)
144145
->addViolation();
145146
}

0 commit comments

Comments
 (0)