Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff8bb4b

Browse filesBrowse files
author
Hugo Hamon
committed
[Validator] UuidValidator must accept a Uuid constraint.
1 parent e262ef0 commit ff8bb4b
Copy full SHA for ff8bb4b

File tree

Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed

‎src/Symfony/Component/Validator/Constraints/UuidValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/UuidValidator.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public function validate($value, Constraint $constraint)
8181
return;
8282
}
8383

84+
if (!$constraint instanceof Uuid) {
85+
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Uuid');
86+
}
87+
8488
if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
8589
throw new UnexpectedTypeException($value, 'string');
8690
}

‎src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ public function testEmptyStringIsValid()
4444
$this->assertNoViolation();
4545
}
4646

47+
/**
48+
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
49+
*/
50+
public function testExpectsUuidConstraintCompatibleType()
51+
{
52+
$constraint = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\Constraint');
53+
54+
$this->validator->validate('216fff40-98d9-11e3-a5e2-0800200c9a66', $constraint);
55+
}
56+
4757
/**
4858
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
4959
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.