vlid icon indicating copy to clipboard operation
vlid copied to clipboard

Bug in async cast

Open nathandem opened this issue 4 years ago • 0 comments

First off, thank you for this nice, lightweight library! It's a nice replacement to the heavy joi without losing the "80%" as you put it :)

I noticed an issue around number casting when using validate, while it's still working fine with validateSync.

I confirmed this by adding this small test in __tests__/numbers.js:

    it('should cast strings with numbers in them to numbers (async)', async () => {
      let result = await v.validate(v.number().cast(), '1');

      isValidWithoutErrors(result);
      expect(result.value).toBe(1);
    });

It failed.

I don't know how you want to approach this, but I feel like it would be good to have some tests with validate. Probably not a duplicate of every existing synchronous tests, but a few "integration" tests with more complex payloads like this one.

nathandem avatar Apr 11 '20 16:04 nathandem