mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Update src/Appwrite/Utopia/Database/Validator/Operation.php
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
a9a97b2fe0
commit
45da32d5d9
1 changed files with 16 additions and 5 deletions
|
|
@ -127,14 +127,25 @@ class Operation extends Validator
|
|||
}
|
||||
|
||||
// If action requires documentId, it must be present
|
||||
if (
|
||||
isset($this->requiresDocumentId[$value['action']]) &&
|
||||
!\array_key_exists($this->documentIdName, $value)
|
||||
) {
|
||||
- if (
|
||||
- isset($this->requiresDocumentId[$value['action']]) &&
|
||||
- !\array_key_exists($this->documentIdName, $value)
|
||||
- ) {
|
||||
- $this->description = "Key '$this->documentIdName' is required for action '{$value['action']}'";
|
||||
- return false;
|
||||
$actionRequiresDocumentId = ($this->requiresDocumentId[$value['action']] ?? false) === true;
|
||||
if ($actionRequiresDocumentId && !\array_key_exists($this->documentIdName, $value)) {
|
||||
$this->description = "Key '$this->documentIdName' is required for action '{$value['action']}'";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (\array_key_exists($this->documentIdName, $value)) {
|
||||
if (!\is_string($value[$this->documentIdName]) || \trim($value[$this->documentIdName]) === '') {
|
||||
$this->description = "Key '$this->documentIdName' must be a non-empty string";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Data validation - only required for certain actions
|
||||
if (isset($this->requiresData[$value['action']]) && $this->requiresData[$value['action']]) {
|
||||
// Data is required for this action
|
||||
|
|
@ -146,7 +157,7 @@ class Operation extends Validator
|
|||
$this->description = "Key 'data' must be an array";
|
||||
return false;
|
||||
}
|
||||
} elseif (\array_key_exists('data', $value)) {
|
||||
} else if (\array_key_exists('data', $value)) {
|
||||
// Data is optional but if provided, must be an array
|
||||
if (!\is_array($value['data'])) {
|
||||
$this->description = "Key 'data' must be an array";
|
||||
|
|
|
|||
Loading…
Reference in a new issue