Giter VIP home page Giter VIP logo

Comments (6)

fabian-hiller avatar fabian-hiller commented on August 26, 2024 1

This is because not every path item has a .key property, but I plan to improve the developer experience on this part by adding key: undefined in this case.

from valibot.

peterbe avatar peterbe commented on August 26, 2024 1

So trick is, use:

  } catch (error) {
    if (v.isValiError(error)) {

not

  } catch (error) {
    if (error instanceof v.ValiError) {

from valibot.

fabian-hiller avatar fabian-hiller commented on August 26, 2024

Nowhere in that thrown error does it say what key in the parsed object that was causing the Expected boolean but received undefined.

This information can be found under the .path key of each issue. Your console just doesn't show it all, but that's out of our control. The data is there.

By why is the error.issues[0].path of type any[]?

Something is wrong here, but everything looks fine on my machine. What version of Valibot are you using? Can you share your schema and the shown code with me?

Perhaps I'm missing something obvious but figuring out which key in my object schema the error was about was very hard.

You can also pass the issue to v.getDotPath<TSchema>(issue) to get its path.

from valibot.

foster-hangdaan avatar foster-hangdaan commented on August 26, 2024

I have a similar issue when trying to access the path key within a ValiError. I am getting some options but key is not one of them:

image

I am using Valibot v0.35.0.

from valibot.

fabian-hiller avatar fabian-hiller commented on August 26, 2024

v0.36.0 is available

from valibot.

fabian-hiller avatar fabian-hiller commented on August 26, 2024

Yes, but even better is: v.isValiError<typeof Schema>(error)

from valibot.

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.