question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`.strict()` and `.and()` combined is not working

See original GitHub issue

Bug description

The method .strict() and .and() combined results in an unexpected parsing error.

Zod version

3.0.0-alpha.33

Playground

const a = z.object({ a: z.string() }).strict();
const b = z.object({ b: z.string() }).strict();
const c = a.and(b);

c.parse({ a: "a", b: "b" });

Output

error: ZodError: [
    {
      "code": "unrecognized_keys",
      "keys": [
        "b"
      ],
      "path": [],
      "message": "Unrecognized key(s) in object: 'b'"
    },
    {
      "code": "unrecognized_keys",
      "keys": [
        "a"
      ],
      "path": [],
      "message": "Unrecognized key(s) in object: 'a'"
    }
  ]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
colinhackscommented, Apr 25, 2021

By the way, I just added an Ecosystem section to the README to boost projects like yours: https://github.com/colinhacks/zod/tree/v3#ecosystem

1reaction
fabien0102commented, Apr 26, 2021

Don’t worry, I also have a lot of work and I totally understand than side-projects are not always a priority (and can be sometime hard to manage on top of all other stuff going on 😅 )

Read more comments on GitHub >

github_iconTop Results From Across the Web

What happens when you combine "use strict"; inside functions ...
It seems that when "use strict"; is both in the global context and in a function, they cancel out, since when I remove...
Read more >
Strict equality (===) - JavaScript - MDN Web Docs
The strict equality (===) operator checks whether its two operands are equal, returning a Boolean result. Unlike the equality operator, the strict equality ......
Read more >
JavaScript "use strict" - W3Schools
In strict mode, any assignment to a non-writable property, a getter-only property, a non-existing property, a non-existing variable, or a non-existing object, ...
Read more >
If the code stops working when 'use strict' is added to it ... - Quora
Strict mode makes several changes to normal JavaScript semantics. First, strict mode eliminates some JavaScript silent errors by changing them to throw errors....
Read more >
strict-dynamic in CSP - Content Security Policy
Support for nonce would still work in CSP Level 2 browsers, but not in CSP Level 1. Thankfully the authors of CSP Level...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found