imbrn / v8n

☑️ JavaScript fluent validation library

Home Page:https://imbrn.github.io/v8n

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: nested async rules

havelaer opened this issue · comments

Async rules are not tested async when placed within a schema.

  test("nested async rule", async () => {
    v8n.extend({ asyncRule });

    const validation = v8n().schema({
      item: v8n().number().asyncRule([10, 17, 20]),
    });

    await expect(validation.testAsync({ item: "10" })).rejects.toBeDefined();
    await expect(validation.testAsync({ item: 11 })).rejects.toBeDefined(); // -> expect failes, because asyncRule is not validated async.
    await expect(validation.testAsync({ item: 17 })).resolves.toBe({ item: 17 });
  });

Thank you @havelaer for your report, I'll check this.