Skip to content

Commit 007fe0a

Browse files
jperovicfabpot
authored andcommitted
Added {{ value }} message placeholder to UniqueEntityValidator
1 parent 5fffdd7 commit 007fe0a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

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

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
}

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)