livewire / volt

Volt is an elegantly crafted functional API for Livewire.
https://livewire.laravel.com/docs/volt
MIT License
312 stars 19 forks source link

Can't use closures for validation #66

Closed GithubEficienciaTributaria closed 8 months ago

GithubEficienciaTributaria commented 8 months ago

Volt Version

1.4

Laravel Version

10.31.0

PHP Version

8.2

Database Driver & Version

mariadb 10.4.31

Description

When trying to setup dynamic validation for my component, I used a closure inside the rules function, but when I try to access the page with my component, I get the following error: array_merge(): Argument #2 must be of type array, Closure given.

Steps To Reproduce

  1. Create a livewire volt component
  2. Create a validation with a closure like, rules(fn () => [ 'name' => ['required'] ]);
  3. Reload the page.

error

RVxLab commented 8 months ago

I saw this happen on 1.3.x as well. Let me see if I can make a PR for this.

RVxLab commented 8 months ago

Made a PR for this and got it working locally.

driesvints commented 8 months ago

Thanks all. Let's see how the PR goes.