Skip to content

Commit 422d3c1

Browse files
committed
feat: Adds support for lazy loading data
1 parent ebe1167 commit 422d3c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public function validateCallable(array|ArrayObject $data, callable $call): array
153153
$aliasName = $this->getAliasName($parameter, $defaultAliasGenerator);
154154
$this->context->push('internal.currentProperty', $propertyName);
155155

156-
if (! array_key_exists($aliasName, (array) $data) && ! array_key_exists($index, (array) $data)) {
156+
$propertyValue = $data[$index] ?? $data[$aliasName] ?? null; // Lazy load data
157+
if (! array_key_exists($index, (array) $data) && ! array_key_exists($aliasName, (array) $data)) {
157158
if (! $parameter->isDefaultValueAvailable()) {
158159
try {
159160
$errorInfo->addError("Missing required argument '$aliasName'");
@@ -167,7 +168,6 @@ public function validateCallable(array|ArrayObject $data, callable $call): array
167168
continue;
168169
}
169170

170-
$propertyValue = $data[$index] ?? $data[$aliasName];
171171
$property = new Property($parameter, $propertyValue);
172172
$this->context->set(Property::class, $property, override: true);
173173

0 commit comments

Comments
 (0)