From 70ef7059c309db4d3e4d5738606116aa6f6cb33f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 3 Sep 2025 03:42:19 +1200 Subject: [PATCH] Add increment validation --- .../Utopia/Database/Validator/Operation.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Utopia/Database/Validator/Operation.php b/src/Appwrite/Utopia/Database/Validator/Operation.php index 25b9adcd9a..594648db3e 100644 --- a/src/Appwrite/Utopia/Database/Validator/Operation.php +++ b/src/Appwrite/Utopia/Database/Validator/Operation.php @@ -13,7 +13,6 @@ class Operation extends Validator 'databaseId', 'collectionId', 'action', - 'data', ]; /** @var array */ @@ -22,6 +21,8 @@ class Operation extends Validator 'update' => true, 'upsert' => true, 'delete' => true, + 'increment' => true, + 'decrement' => true, ]; /** @var array */ @@ -30,6 +31,8 @@ class Operation extends Validator 'update' => true, 'upsert' => true, 'delete' => true, + 'increment' => true, + 'decrement' => true, 'bulkCreate' => true, 'bulkUpdate' => true, 'bulkUpsert' => true, @@ -75,7 +78,7 @@ class Operation extends Validator // Validate action if (!isset($this->actions[$value['action']])) { - $this->description = "Key 'action' must be one of: " . \implode(', ', $this->actions); + $this->description = "Key 'action' must be one of: " . \implode(', ', array_keys($this->actions)); return false; } @@ -88,7 +91,11 @@ class Operation extends Validator return false; } - // Data must be array (can be empty) + // Data must be present and must be array (can be empty) + if (!\array_key_exists('data', $value)) { + $this->description = "Missing required key: data"; + return false; + } if (!\is_array($value['data'])) { $this->description = "Key 'data' must be an array"; return false;