-
Notifications
You must be signed in to change notification settings - Fork 55
Fix validation #749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix validation #749
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,9 @@ | |
| use Utopia\Database\Database; | ||
| use Utopia\Database\Document; | ||
| use Utopia\Database\Exception as DatabaseException; | ||
| use Utopia\Database\Operator; | ||
| use Utopia\Database\Validator\Datetime as DatetimeValidator; | ||
| use Utopia\Database\Validator\Operator as OperatorValidator; | ||
| use Utopia\Validator; | ||
| use Utopia\Validator\Boolean; | ||
| use Utopia\Validator\FloatValidator; | ||
|
|
@@ -106,7 +108,8 @@ public function __construct( | |
| private readonly string $idAttributeType, | ||
| private readonly \DateTime $minAllowedDate = new \DateTime('0000-01-01'), | ||
| private readonly \DateTime $maxAllowedDate = new \DateTime('9999-12-31'), | ||
| private bool $supportForAttributes = true | ||
| private bool $supportForAttributes = true, | ||
| private readonly ?Document $currentDocument = null | ||
| ) { | ||
| } | ||
|
|
||
|
|
@@ -305,6 +308,18 @@ protected function checkForUnknownAttributes(array $structure, array $keys): boo | |
| protected function checkForInvalidAttributeValues(array $structure, array $keys): bool | ||
| { | ||
| foreach ($structure as $key => $value) { | ||
| if (Operator::isOperator($value)) { | ||
| // Set the attribute name on the operator for validation | ||
| $value->setAttribute($key); | ||
|
|
||
| $operatorValidator = new OperatorValidator($this->collection, $this->currentDocument); | ||
| if (!$operatorValidator->isValid($value)) { | ||
| $this->message = $operatorValidator->getDescription(); | ||
| return false; | ||
| } | ||
|
Comment on lines
+311
to
+319
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle array-backed attribute metadata before invoking OperatorValidator
🤖 Prompt for AI Agents |
||
| continue; | ||
| } | ||
|
|
||
| $attribute = $keys[$key] ?? []; | ||
| $type = $attribute['type'] ?? ''; | ||
| $array = $attribute['array'] ?? false; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.