Bug: nested async rules
havelaer opened this issue · 1 comments
havelaer commented
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 });
});