laravel / precognition

Anticipate the outcome of a future HTTP request.
https://laravel.com/docs/precognition
MIT License
136 stars 34 forks source link

Validate only field in touch #94

Closed msirse closed 2 months ago

msirse commented 2 months ago

Laravel Precognition Plugin Version

0.5.8

Laravel Version

11.0

Plugin

Vue w/ Inertia

Description

When you have multi step wizard, and would you like validate each step seperate. The second validate will validate first and second fields. It would be logical to validate only the fields listed in the touch function

Steps To Reproduce

const form = useForm('post', route, {
    first_name: "",
    last_name: "",
    address: ",
    post_code: "",
    city: "",
});

Step 1
 form.touch(["first_name", "last_name"]).validate({
        onSuccess: (response) => {
           nextStep()
        },
    });

Header:
precognition-validate-only: first_name,last_name

Step 2
form.touch(["address", "post_code, "city"]).validate({
        onSuccess: (response) => {
           nextStep()
        },
  });

Header:
precognition-validate-only: first_name,last_name,address,post_code,city
timacdonald commented 2 months ago

This is the intended behaviour. Happy to look at this more but you have not provided information about the bug you are experiencing.

Reply with more information and we can reopen the issue.