Skip to content

Issues with async validation and wizard #98

Closed
@ahme-d

Description

@ahme-d

Laravel Precognition Plugin Version

0.5.8

Laravel Version

11.0

Plugin

Vue w/ Inertia

Description

This is slightly similar to #95 but I'd like to highlight the issue I'm facing with wizard use-case.

In the below example from #69 & Laravle docs, onSuccess() wouldn't trigger if the inputs have already been validated

<Button 
    @click="form.touch(['name', 'email', 'address', 'phone']).validate({
        onSuccess: () => nextPage(),
        onValidationError: () => notify('You have validation errors'),
    })"
>
    Next
</Button>

This means we cannot mix @change="form.validate('any') on an input alongside the button because all of the would have all been validated.

Also makes it difficult to have a previous button in a wizard.

This would have been a quick/clean thing to solve if form.valid() can validate an array instead of one key at a time or to have onValid() in validate.

Steps To Reproduce

function nextStep() {

    const formElements = [
        ["first_name", "last_name"],
        ["email", "password"],

    ];

    form.touch(formElements[activeStep.value]).validate({
        onSuccess: () => {
            activeStep.value += 1;
        }
    });

}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions