Cerys
4 weeks ago
3 changed files with 37 additions and 1 deletions
@ -0,0 +1,15 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\DeegraphInteractions\Utilities; |
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderInvalidInputException; |
||||
|
|
||||
|
class RelativePath |
||||
|
{ |
||||
|
public static function Validate(string $target): bool |
||||
|
{ |
||||
|
if (!preg_match(pattern: "/(^(\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\})$)|(^\{[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}\}(\/([a-z][a-z0-9]*|[0-9]+|#|\*))+$)|(^(([a-z][a-z0-9]*|[0-9]+|#|\*))(\/([a-z][a-z0-9]*|[0-9]+|#|\*))*$)/", subject: $target)) |
||||
|
return false; |
||||
|
return true; |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
use Darksparrow\DeegraphInteractions\Exceptions\QueryBuilderConflictingFieldAlreadyExistsException; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilder; |
||||
|
use Darksparrow\DeegraphInteractions\QueryBuilder\QueryBuilderTrait; |
||||
|
use Darksparrow\DeegraphInteractions\Utilities\RelativePath; |
||||
|
use PHPUnit\Framework\TestCase; |
||||
|
|
||||
|
final class ValidateDeegraphPathTest extends TestCase |
||||
|
{ |
||||
|
public function testValidUUID() |
||||
|
{ |
||||
|
self::assertTrue(RelativePath::Validate("{00000000-0000-0000-0000-000000000000}")); |
||||
|
} |
||||
|
public function testFullStop() |
||||
|
{ |
||||
|
self::assertTrue(RelativePath::Validate(".")); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue