You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like the validation_strategy set to always is designed to validate all properties, including nested data.
Based on the documentation, the Event data appears to be nested within the history collection, which itself is nested within the Post object. This suggests that the validation rules for Event should be defined within a nested rules structure, similar to:
However, in Laravel, the present rule requires the field to exist. If the params property is optional, you might consider making it nullable in your Event class:
public function __construct(
public string $name,
- public array $params = [],+ public ?array $params = [],
) {}
This change would ensure that the validation rule for params is only applied when the field is actually present.
✏️ Describe the bug
I am using version 4.10.1 and also i have
validation_strategy
set toalways
.↪️ To Reproduce
I'm getting following exception:
✅ Expected behavior
De-serialization should happen also when
params
are not set as the default value (empty array) is set in data object definition.🖥️ Versions
Laravel: 11
Laravel Data: 4.10.1
PHP: 8.3
The text was updated successfully, but these errors were encountered: