A little late to respond but one accepted way to extract validation logic is to add it to the model. It looks like this:
// Model.php public static function validationRules() { return [ 'name' => ['required', 'string', 'max:250'], 'other_attr' => ['nullable', 'url', 'max:250'], 'another_attr' => ['nullable', 'string', 'max:250'] ]; }
Then in Livewire you can do:
// Livewire component public function store() { $this->validate(Model::validationRules); }
That's pretty nice. But it will be more pretty strecture like CustomFormRequest. Anyway Thank You so much
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A little late to respond but one accepted way to extract validation logic is to add it to the model. It looks like this:
Then in Livewire you can do:
That's pretty nice. But it will be more pretty strecture like CustomFormRequest. Anyway Thank You so much