default value for optional field

Hey! I have a question about handling optional fields with defaults. I want to define a type where a property is optional in the input, but its value should never be undefined. If the field is missing entirely, I want to transform the input so that the field is present in the result with a default value. Using pipe() seems to only work when the property is defined
1 Reply
ssalbdivad
ssalbdivad•3mo ago
ArkType
ArkType Docs
TypeScript's 1:1 validator, optimized from editor to runtime

Did you find this page helpful?