Create Appwrite Query Validator
The Appwrite Query Validator checks if the cursor value is a valid UID. This is different than the cursor value in utopia-php/database because the value in the database layer is expected to be a document.
This commit is contained in:
parent
bc9e928187
commit
753aebccab
1 changed files with 21 additions and 0 deletions
21
src/Appwrite/Utopia/Database/Validator/Query.php
Normal file
21
src/Appwrite/Utopia/Database/Validator/Query.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Database\Validator;
|
||||
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Database\Validator\Query as QueryValidator;
|
||||
|
||||
class Query extends QueryValidator
|
||||
{
|
||||
protected function isValidCursor($cursor): bool
|
||||
{
|
||||
$validator = new UID();
|
||||
|
||||
if ($validator->isValid($cursor)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->message = 'Invalid cursor: ' . $validator->getDescription();
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue