Skip to content

Commit 94919f2

Browse files
author
Barry O Sullivan
authored
Merge pull request #8 from barryosull/feature/bug-with-overly-long-uuids
Fixing a bug where it accepted overly long UUIDs
2 parents 82c62b3 + 9f6b6bb commit 94919f2

4 files changed

Lines changed: 36 additions & 30 deletions

File tree

composer.lock

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ValueObject/Uuid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Uuid extends Type\AbstractSingleValue implements Identifier
77
{
88
protected function validator()
99
{
10-
return parent::validator()->regex('/([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)/i');
10+
return parent::validator()->regex('/([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)$/i');
1111
}
1212

1313
public function is_null()

test/Deserializer/CompositeErrorReporting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function test_reporting_when_values_are_wrong()
2626
$exception = $this->fail_elegantly($encoded);
2727

2828
$expected = [
29-
"id" => ['"1234" must validate against "/([a-f\\\\d]{8}(-[a-f\\\\d]{4}){3}-[a-f\\\\d]{12}?)/i"'],
29+
"id" => ['"1234" must validate against "/([a-f\\\\d]{8}(-[a-f\\\\d]{4}){3}-[a-f\\\\d]{12}?)$/i"'],
3030
"date" => ['"saads" must be a valid date']
3131
];
3232

test/ValueObject/Uuid.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ public function test_invalid_value()
1515
$this->setExpectedException(Assert\Exception::class);
1616
new Uuid("asdfasdf");
1717
}
18+
19+
public function test_fails_if_the_uuid_is_too_long()
20+
{
21+
$this->setExpectedException(Assert\Exception::class);
22+
new Uuid("ac9e4e83-5495-4a58-90d9-eeeaf3989bc8a");
23+
}
1824
}

0 commit comments

Comments
 (0)