add getDefaults method #584
Answered
by
franky47
NurbekGithub
asked this question in
Ideas
-
Valibot and Zod has a getDefaults method where you can get default values from schema. |
Beta Was this translation helpful? Give feedback.
Answered by
franky47
Jul 6, 2024
Replies: 1 comment 5 replies
-
You can get the default value from a configured parser: import { parseAsInteger } from 'nuqs'
const parser = parseAsInteger.withDefault(42)
parser.defaultValue // 42 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your first code example can be done with a simple function (simple at runtime, but harder to make type-safe; PR #578 might help here):
Now, your second code example could work, but going through the serializer could be expensive.
I…