Skip to content

bug in record rule? #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hugebdu opened this issue Aug 28, 2022 · 1 comment · Fixed by #308
Closed

bug in record rule? #307

hugebdu opened this issue Aug 28, 2022 · 1 comment · Fixed by #308

Comments

@hugebdu
Copy link
Contributor

hugebdu commented Aug 28, 2022

I suspect that the record rule resets the value.
this test fails for me:

import Validator from "fastest-validator";

describe("record rule", () => {
  it("should not mutate valid value", async () => {
    expect.hasAssertions();
    const validate = new Validator().compile({
      foo: {
        type: "record",
        key: "string",
        value: "string",
      },
    });

    const value = { foo: { bar: "baz" } };
    expect(validate(value)).toBe(true);
    expect(value).toStrictEqual({ foo: { bar: "baz" } });
  });
});

with error

Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 3
+ Received  + 1

  Object {
-   "foo": Object {
-     "bar": "baz",
-   },
+   "foo": undefined,
  }
@icebob
Copy link
Owner

icebob commented Aug 28, 2022

@FFKL could you check it plz?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants