@ -8,7 +8,7 @@ use Darksparrow\DeegraphPHP\Exceptions\QueryBuilderInvalidInputException;
trait QueryBuilderTrait
trait QueryBuilderTrait
{
{
protected function Validate(string $target, string $pattern): string
protected function RegexValidate(string $target, string $pattern): string
{
{
if (!preg_match(pattern: $pattern, subject: $target))
if (!preg_match(pattern: $pattern, subject: $target))
throw new QueryBuilderInvalidInputException();
throw new QueryBuilderInvalidInputException();
@ -20,4 +20,11 @@ trait QueryBuilderTrait
if ($target != "")
if ($target != "")
throw new QueryBuilderConflictingFieldAlreadyExistsException();
throw new QueryBuilderConflictingFieldAlreadyExistsException();
}
}
protected function ValidateDeegraphPath(string $target): string
{
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))