Comments (6)
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.
So trick is, use:
} catch (error) {
if (v.isValiError(error)) {
not
} catch (error) {
if (error instanceof v.ValiError) {
from valibot.
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 typeany[]
?
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.
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:
I am using Valibot v0.35.0.
from valibot.
v0.36.0 is available
from valibot.
Yes, but even better is: v.isValiError<typeof Schema>(error)
from valibot.
Related Issues (20)
- transform does not work with fallback if union is also used... HOT 2
- Help with checking if minimum 1 element of the array doesn't have empty string. HOT 6
- How to create dynamic variants with the nested schemas? HOT 1
- [FEATURE] check and checkAsync can accept message (string) in return HOT 2
- v.record numbers as keys HOT 1
- checkAsync with valibotResolver not working HOT 1
- [feat suggestion]: partial/nullish/nullable object with default values HOT 1
- "Cannot read properties of null" when using trim with nullish HOT 4
- algolia search not working HOT 2
- Preserve `@ts-expect-error` directives HOT 7
- feat: Add TransformStream Validation HOT 1
- Add an example for handling ValiError errors HOT 10
- Using variant with a nested key HOT 1
- Add length validators based on the `Intl.Segmenter` API HOT 1
- What should I put inside the pipe HOT 1
- May we make `function_()` generic? HOT 4
- nested prop of flattened issues is typed as '{} | undefined' when object schema is piped to forward HOT 2
- Nested variants HOT 9
- As of 0.38.0 `transform` breaks `pipe` in some cases HOT 13
- `forward` breaks `pipe` in >=v0.38.x HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from valibot.