Skip to content
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

getDefault() doesn't work with object schemas? #884

Closed
laneme opened this issue Oct 18, 2024 · 2 comments
Closed

getDefault() doesn't work with object schemas? #884

laneme opened this issue Oct 18, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@laneme
Copy link

laneme commented Oct 18, 2024

 const OptionalStringSchema = v.object({
    cake: v.optional(v.string(), "Chocolate!"),
 })
 const defaultValue = v.getDefault(OptionalStringSchema)
 console.info(defaultValue) // undefined

Its even typed undefined. Is this something not implemented yet?

It works with the primitives tho

v.getDefault(OptionalStringSchema.entries.cake) // Chocolate

Versions

"valibot": "^0.42.1",
"typescript": "~5.6.3",
@fabian-hiller
Copy link
Owner

Please have a look at getDefaults: https://valibot.dev/api/getDefaults/

@fabian-hiller fabian-hiller self-assigned this Oct 18, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Oct 18, 2024
@laneme
Copy link
Author

laneme commented Oct 18, 2024

Silly me just ignoring the letter s. Ty ^^

@laneme laneme closed this as completed Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants