Skip to content

Commit 8ded94d

Browse files
committed
feat: validates that successful oepration has result
1 parent 342c07a commit 8ded94d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Operations/DTO/GenerativeAiOperation.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ public static function fromArray(array $array): self
175175
static::validateFromArrayData($array, [self::KEY_ID, self::KEY_STATE]);
176176

177177
$state = OperationStateEnum::from($array[self::KEY_STATE]);
178+
179+
if ($state->isSucceeded()) {
180+
// If the operation has succeeded, it must have a result
181+
static::validateFromArrayData($array, [self::KEY_RESULT]);
182+
}
183+
178184
$result = null;
179185
if (isset($array[self::KEY_RESULT])) {
180186
$result = GenerativeAiResult::fromArray($array[self::KEY_RESULT]);

0 commit comments

Comments
 (0)