v.optional after transform to undefined #801
Unanswered
IlyaSemenov
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Can you provide a playground link that reproduces the problem? |
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
-
I'd like to create a schema for parsing values that are either strings (in fact, only
""
) or numbers. For context, this type of data is coming from Vue<input v-model.number="field">
.For numbers, I want to keep them, for
""
, I'd like to getundefined
.This is what I have currently:
Then I can use it like this:
This kinda works, but the optional/non-optional handling is reversed compared to the built-in schemas. Also, the inferred return type for
requiredNumber
isnumber | undefined
which is not correct.All and all, I'd like the end-user code to be something more like:
How do I build
inputNumber2
for the case above?Beta Was this translation helpful? Give feedback.
All reactions