mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
fix: use RELATIONSHIP_VALUE_INVALID exception for validation errors
This commit is contained in:
parent
7f3ea98924
commit
aef7b8df38
1 changed files with 5 additions and 2 deletions
|
|
@ -265,13 +265,16 @@ abstract class Action extends DatabasesAction
|
||||||
} elseif (\is_array($relation) && !\array_is_list($relation)) {
|
} elseif (\is_array($relation) && !\array_is_list($relation)) {
|
||||||
$relationId = $relation['$id'] ?? null;
|
$relationId = $relation['$id'] ?? null;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Relationship value must be an object, document ID string, or associative array');
|
throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, 'Relationship value must be an object, document ID string, or associative array');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($relationId !== null) {
|
if ($relationId !== null) {
|
||||||
|
if (!\is_string($relationId)) {
|
||||||
|
throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, 'Relationship $id must be a string');
|
||||||
|
}
|
||||||
$validator = new CustomId();
|
$validator = new CustomId();
|
||||||
if (!$validator->isValid($relationId)) {
|
if (!$validator->isValid($relationId)) {
|
||||||
throw new Exception(Exception::GENERAL_BAD_REQUEST, $validator->getDescription());
|
throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, $validator->getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue