Skip to content

Commit

Permalink
test: Assert that float nested in an object inside an array convert t…
Browse files Browse the repository at this point in the history
…o "numeric" rule
  • Loading branch information
bezhermoso committed Feb 16, 2024
1 parent 37ce129 commit 5a51f45
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/BuilderTypedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,48 @@ public function testNodeAsPathParam(): void
'bar.baz.foo' => ['integer', 'required_without:bar.foo'],
], $builder->build());
}

public function testFloatInsideRepeatedObject(): void
{
$builder = Hyrule::create();

$builder = $builder
->array('areas')
->each('object')
->object('coordinates')
->nullable()
->float('latitude')
->nullable()
->end()
->float('longitude')
->nullable()
->end()
->end()
->end()
->end();
$rules = $builder->build();

$this->assertEquals(
[
'' => [new KnownPropertiesOnly(['areas'])],
'areas' => ['array'],
'areas.*' => [
new KnownPropertiesOnly(['coordinates']),
],
'areas.*.coordinates' => [
new KnownPropertiesOnly(['latitude', 'longitude']),
'nullable',
],
'areas.*.coordinates.latitude' => [
'numeric',
'nullable',
],
'areas.*.coordinates.longitude' => [
'numeric',
'nullable',
]
],
$rules,
);
}
}

0 comments on commit 5a51f45

Please sign in to comment.