Skip to content

Commit

Permalink
Merge pull request #8 from barryosull/feature/bug-with-overly-long-uuids
Browse files Browse the repository at this point in the history
Fixing a bug where it accepted overly long UUIDs
  • Loading branch information
Barry O Sullivan authored Jul 24, 2017
2 parents 82c62b3 + 9f6b6bb commit 94919f2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
56 changes: 28 additions & 28 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ValueObject/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Uuid extends Type\AbstractSingleValue implements Identifier
{
protected function validator()
{
return parent::validator()->regex('/([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)/i');
return parent::validator()->regex('/([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)$/i');
}

public function is_null()
Expand Down
2 changes: 1 addition & 1 deletion test/Deserializer/CompositeErrorReporting.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_reporting_when_values_are_wrong()
$exception = $this->fail_elegantly($encoded);

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

Expand Down
6 changes: 6 additions & 0 deletions test/ValueObject/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ public function test_invalid_value()
$this->setExpectedException(Assert\Exception::class);
new Uuid("asdfasdf");
}

public function test_fails_if_the_uuid_is_too_long()
{
$this->setExpectedException(Assert\Exception::class);
new Uuid("ac9e4e83-5495-4a58-90d9-eeeaf3989bc8a");
}
}

0 comments on commit 94919f2

Please sign in to comment.