Giter Club home page Giter Club logo

Comments (8)

RobinTail avatar RobinTail commented on July 28, 2024 1

Well-well-well...
You're assigning a number to the property having schema z.coerce.string().
Typescript validates the handler's returns using z.input< typeof z.coerce.string() >, and it seems to be just string, so you're getting an error.
I'd say, that this is more likely the zod's issue of the way the schemas with coercion being inferred.

But I'll check it more precisely tomorrow.
Thank you for letting me know, @teaishealthy

from express-zod-api.

teaishealthy avatar teaishealthy commented on July 28, 2024 1

I think it's not about bigint, it's about your name property, which is string, but you're assigning a number to it,

I don't think my provided example was directly related to the schema issue, I just found it while tinkering around. I can try to provide an example later this day.

from express-zod-api.

RobinTail avatar RobinTail commented on July 28, 2024 1

I don't think my provided example was directly related to the schema issue, I just found it while tinkering around. I can try to provide an example later this day.

I checked the example in details — it's fine and it really reveals the confusion with the new coercion feature in Zod.
The problem is that coerce feature is not reflected on the type level, it only works in runtime.

I posted a more generic issue in Zod repo with a question to Colin. Maybe they would explain should it be fixed or it's somehow intentional.

colinhacks/zod#1760

Anyway, thank you @teaishealthy

from express-zod-api.

RobinTail avatar RobinTail commented on July 28, 2024 1

The issue confirmed as a bug of zod, @teaishealthy
colinhacks/zod#1760 (comment)

from express-zod-api.

RobinTail avatar RobinTail commented on July 28, 2024 1

I made a PR that should fix the issue in zod, but I'm still waiting for its approval.
colinhacks/zod#1793

from express-zod-api.

RobinTail avatar RobinTail commented on July 28, 2024

Bad news, @teaishealthy .
The author of zod confirmed the bug, but does not want to fix it (now), since according to the author's vision it requires a complete refactoring of zod to be less messy.
¯\_(ツ)_/¯
Not sure yet what I can do about it...

from express-zod-api.

teaishealthy avatar teaishealthy commented on July 28, 2024

That's really unfortunate 😕 although I should be able to get along without .coere for the time being

Anyway thank you for your efforts on this issue 👍

from express-zod-api.

RobinTail avatar RobinTail commented on July 28, 2024

Regarding z.coerce.bigint() — this is also third party bug:
colinhacks/zod#1911

from express-zod-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.