Skip to content

Commit

Permalink
Revert "Fix issue where non set optional values were transformed"
Browse files Browse the repository at this point in the history
This reverts commit 3b63875.

# Conflicts:
#	tests/ValidationTest.php
  • Loading branch information
rubenvanassche committed Oct 20, 2023
1 parent f47d3f0 commit dea1e75
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
4 changes: 0 additions & 4 deletions src/Transformers/DataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ protected function resolvePayload(TransformableData $data): array

$name = $property->name;

if ($property->type->isOptional && ! isset($data->{$name})) {
continue;
}

if (! $this->shouldIncludeProperty($name, $data->{$name}, $trees)) {
continue;
}
Expand Down
10 changes: 0 additions & 10 deletions tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2379,13 +2379,3 @@ public static function rules(ValidationContext $context): array
->assertOk(['success' => true, 'id' => 1])
->assertErrors(['success' => true]);
})->skip('V4: The rule inferrers need to be rewritten/removed for this, we need to first add attribute rules and then decide require stuff');

it('will not transform non set optional properties ', function () {
$dataClass = new class () extends Data {
public array|Optional $optional;
};

expect($dataClass::from([])->toArray())->toBeEmpty();
expect($dataClass::from()->toArray())->toBeEmpty();
expect((new ($dataClass::class))->toArray())->toBeEmpty();
});

0 comments on commit dea1e75

Please sign in to comment.