aabad_ankit
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
Thank you so much for all the help
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
@ArkDavid You were suggesting to use narrow, can I do it on union and solve my problem
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
a code sample will be super useful
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
but delete on undeclared key will work on union right once you have built in discrimination based on key presence
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
This prints
age must be a number (was missing) or city must be a string (was missing)
. I just want the error msg to be age must be a number (was missing)
to do that I am currently doing something like this
so I wanted to know if there is more idiomatic way to do this66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
@ArkDavid @Dimava the Monoreaper What will be the most idiomatic way to do the validation for such union types to get correct error msg. Do I need to check for the properties and do validation by creating a validator map
This is getting verbose.
I am giving example of just one field but my inputs are larger and I have 5 different types of input. If I could have done union then I would have declared on deepUndeclaredkey("delete") on just the union as well as the pipe on the union
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
Oh Yeah, Understood 👍
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
I am getting
name must be a string (was missing) or city must be a string (was missing)
for both the code snippets below.
and
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
@ArkDavid How can I get better error msg for this
prints "name must be a string (was missing) or city must be a string (was missing)"
since age is already there shouldn't it just say "name must be a string (was missing) "
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
docs will certainly help.
66 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
I need to learn a lot 🙂 . This library is just awesome.
66 replies
Aarktype
•Created by dibbo on 8/16/2024 in #questions
Latest "keys:distilled" equivalent?
Got it. Thank you
11 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Is there a way to rename the key in parse result
This will work, Thank you
3 replies
Aarktype
•Created by dibbo on 8/16/2024 in #questions
Latest "keys:distilled" equivalent?
Great, any reason why and doesn't work but merge works.
11 replies
Aarktype
•Created by aabad_ankit on 9/4/2024 in #questions
Can I add a default value to a type if everything other satisfies in a union type
@Dimava the Monoreaper If I try this
1. merge is not available on baseType
2. I am not getting the name in the result, it seems the pipe operation is applied in the end
66 replies
Aarktype
•Created by dibbo on 8/16/2024 in #questions
Latest "keys:distilled" equivalent?
@ArkDavid If I add onUndeclaredKey("delete"), I can't further use this type to construct more types
const t = type({
a: "string"
}).onUndeclaredKey("delete")
const t2 = t.and({b:"string"})
11 replies