Skip to content

Commit

Permalink
add stringable support for isUuid (laravel#38330)
Browse files Browse the repository at this point in the history
  • Loading branch information
macbookandrew authored Aug 10, 2021
1 parent 2f44389 commit bc1188d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ public function isAscii()
return Str::isAscii($this->value);
}

/**
* Determine if a given string is a valid UUID.
*
* @return bool
*/
public function isUuid()
{
return Str::isUuid($this->value);
}

/**
* Determine if the given string is empty.
*
Expand Down
6 changes: 6 additions & 0 deletions tests/Support/SupportStringableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public function testIsAscii()
$this->assertFalse($this->stringable('ù')->isAscii());
}

public function testIsUuid()
{
$this->assertTrue($this->stringable('2cdc7039-65a6-4ac7-8e5d-d554a98e7b15')->isUuid());
$this->assertFalse($this->stringable('2cdc7039-65a6-4ac7-8e5d-d554a98')->isUuid());
}

public function testIsEmpty()
{
$this->assertTrue($this->stringable('')->isEmpty());
Expand Down

0 comments on commit bc1188d

Please sign in to comment.