1
0
Fork 0
mirror of synced 2024-07-07 23:46:11 +12:00

Pass attribute to select validator

This commit is contained in:
Jake Barnby 2023-03-24 16:44:28 +13:00
parent c310434eeb
commit 947ad20bad
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 5 additions and 2 deletions

View file

@ -62,12 +62,12 @@ class Base extends Queries
]);
$validators = [
new Select(),
new Limit(),
new Offset(),
new Cursor(),
new Filter($attributes),
new Order($attributes),
new Select($attributes),
];
parent::__construct(...$validators);

View file

@ -61,7 +61,7 @@ class Filter extends Base
foreach ($values as $value) {
$condition = match ($attributeType) {
Database::VAR_RELATIONSHIP => true, // Todo: ?
Database::VAR_RELATIONSHIP => true,
Database::VAR_DATETIME => gettype($value) === Database::VAR_STRING,
default => gettype($value) === $attributeType
};
@ -91,6 +91,7 @@ class Filter extends Base
// Validate method
$method = $query->getMethod();
$attribute = $query->getAttribute();
switch ($method) {
case Query::TYPE_EQUAL:
case Query::TYPE_NOTEQUAL:

View file

@ -41,6 +41,8 @@ class Select extends Base
foreach ($query->getValues() as $attribute) {
if (\str_contains($attribute, '.')) {
// For relationships, just validate the top level.
// Utopia will validate each nested level during the recursive calls.
$attribute = \explode('.', $attribute)[0];
}
if (!isset($this->schema[$attribute]) && $attribute !== '*') {