ealush / vest

Vest ✅ Declarative validations framework

Home Page:https://vestjs.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eager mode does not work in a group/omitWhen/skipWhen

TG-Modality opened this issue · comments

I was trying the eager mode when I noticed that the eager mode was not working in omitWhen.

The scenario I have is a field that has multiple tests that should be tested based on a condition:

omitWhen(exists, () => {
    test('name', 'Error', () => {
        enforce(data.code).isNotEmpty();
    });

    test('name', 'Error', () => {
        enforce(data.code).lengthEquals(2);
    });

    test('name', 'Error', async () =>
        await callToBackend(data.name)
    );
});

The second and the last tests always triggers, even when the first test is failing.

When tests are outside the omitWhen, the call to backend only triggers when the first 2 tests are successful.

@TG-Modality Thank you for reporting this. I tested your scenario and can confirm that this indeed does not work as expected.

I will work on a fix during the weekend.

@ealush Thank you for your quick response.

Hey @TG-Modality. Sorry for taking the time. It took me a while to debug the issue. It was deep inside the core, regarding how nested scopes are being created.

Now that I have the full grasp of the problem, I'll run several tests and release an update within a few days.

@TG-Modality should be fixed in 5.2.7. Please let me know if everything works as expected

@ealush Thank you very much. The eager mode is working in omitWhen and skipWhen.