Live validation doesn't seem to work with Laravel 11
ludoguenet opened this issue · 4 comments
Laravel Precognition Plugin Version
0.5.4
Laravel Version
11.1.1
Plugin
Vue
Description
After modifying my input, no error is returned live. In the Form object, the value of errors remains empty. However, it is filled with the correct error if I manually submit the form.
Steps To Reproduce
Installing a classic version of Laravel 11 and Vue 3, as well as setting up the form identical to the documentation.
Adding simple email validation on the backend:
$request->validate([
'email' => [
'required',
'email',
],
]);
Observing that despite the @change="form.validate('email')"
attribute, errors are not returned live.
My bad. Validation didn't work because I wasn't using FormRequest.
For those wondering, if I understand correctly, a FormRequest
is required since an actual request is sent to the endpoint and the entire middleware stack is executed, but the controller function itself is not. The FormRequest
makes the validation available in a place where it can be reached by the precognition request.