Skip to content

Commit bc1188d

Browse files
add stringable support for isUuid (#38330)
1 parent 2f44389 commit bc1188d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Illuminate/Support/Stringable.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ public function isAscii()
258258
return Str::isAscii($this->value);
259259
}
260260

261+
/**
262+
* Determine if a given string is a valid UUID.
263+
*
264+
* @return bool
265+
*/
266+
public function isUuid()
267+
{
268+
return Str::isUuid($this->value);
269+
}
270+
261271
/**
262272
* Determine if the given string is empty.
263273
*

tests/Support/SupportStringableTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public function testIsAscii()
3131
$this->assertFalse($this->stringable('ù')->isAscii());
3232
}
3333

34+
public function testIsUuid()
35+
{
36+
$this->assertTrue($this->stringable('2cdc7039-65a6-4ac7-8e5d-d554a98e7b15')->isUuid());
37+
$this->assertFalse($this->stringable('2cdc7039-65a6-4ac7-8e5d-d554a98')->isUuid());
38+
}
39+
3440
public function testIsEmpty()
3541
{
3642
$this->assertTrue($this->stringable('')->isEmpty());

0 commit comments

Comments
 (0)