What seems to be the problem:
Seems like I can not validate cast properties, particularly a Collection cast
Steps to Reproduce:
Build a class with a property and cast it to collection.
Try to validate with $this->validate
=== Does not work
Try to validate with Validator::make()
==== Does work
<?php
class EditProduct extends Component
{
public $variants;
protected $casts = [
'variants' => 'collection',
];
private function validateToUpdate()
{
// Does not work
$this->validate([
'variants.*.name' => ['required', 'string'],
]);
// Does work
Validator::make(
['variants' => $this->variants->toArray()],
['variants.*.name' => ['required', 'string']],
)->validate();
return $this;
}
}
Are you using the latest version of Livewire:
versions : * v1.3.2