livewire / volt

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

[1.x] Fix defining rules using a closure #67

Closed RVxLab closed 10 months ago

RVxLab commented 11 months ago

This PR fixes rules being unable to be defined using a closure as defined in the Volt documentation.

By evaluating the closure we can get the defined rules, which then get merged into the rules like normal.

I opted not to use a ternary for the is_callable function call for readability. If you want this to be a ternary, let me know and I'll push a commit for that.

I also see that the tests are failing, I was able to reproduce that locally and fixed it by creating workbench/resources/views directory (mkdir -p workbench/resources/views from the project). Would you like me to add that to this branch or rather have a separate branch for that?

Fixes #66

taylorotwell commented 10 months ago

I do not think we want to evaluate the rules early like this. The whole point of using a Closure is to defer it.

taylorotwell commented 10 months ago

Will need @nunomaduro to take a look.