francis
Explore posts from serversAarktype
•Created by francis on 9/21/2024 in #questions
Is there a recommended way to transform a type union into a discriminated union by adding a tag?
especially the tagged union from definition list which I am using to deal with some horrid APIs where an error is indicated by the presence of a key on an otherwise identical object
13 replies
Aarktype
•Created by francis on 9/21/2024 in #questions
Is there a recommended way to transform a type union into a discriminated union by adding a tag?
I suspect these are not problems only I will have
13 replies
Aarktype
•Created by francis on 9/21/2024 in #questions
Is there a recommended way to transform a type union into a discriminated union by adding a tag?
the 'make a tagged union from a list of definitions', 'require at least one key from an object', etc...
13 replies
Aarktype
•Created by francis on 9/21/2024 in #questions
Is there a recommended way to transform a type union into a discriminated union by adding a tag?
we should collect all this stuff in an
arktype recipes
resource somewhere. Maybe not included in the package, but helpful reusable bits13 replies
Aarktype
•Created by francis on 9/21/2024 in #questions
Is there a recommended way to transform a type union into a discriminated union by adding a tag?
wow, you're amazing
13 replies
Aarktype
•Created by francis on 9/21/2024 in #questions
Is there a recommended way to transform a type union into a discriminated union by adding a tag?
(gentle bump - is there a better way than piping on each schema that makes up the union? also, still not sure how to pipe to a named function variable rather than an inline arrow one in a way that typechecks)
13 replies
Aarktype
•Created by francis on 9/23/2024 in #questions
How would you define an object with optional keys, but require at least one of the keys to be filled
(the above doesn't work in a world where you allow extra keys, fyi - though I don't actually need this anymore, I found a different solution)
15 replies
Aarktype
•Created by francis on 9/23/2024 in #questions
How would you define an object with optional keys, but require at least one of the keys to be filled
it would be nice to have a 'best practices' way to do this, either added as a function somewhere in the arktype package, or as a documentation resource
15 replies
Aarktype
•Created by francis on 9/23/2024 in #questions
How would you define an object with optional keys, but require at least one of the keys to be filled
ah, I wasn't asking for a default change, to be clear
15 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
I think my underlying ask is that outside of unions, where we can match the intuitive composition behavior, it would be nice to do so
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
I don't actually know how this works currently. Say you have two branches, each of which has morphs from the same input type, say one is a numeric parse and the other is a date parse, and then follow-up validation on those. What happens if you union those together?
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
yeahhhh.... hm
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
well in a union, I don't expect all errors to be reported for a very simple reason: if branch B matches, I don't care about all the errors from branch A
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
well, it depends on how errors are reported
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
oh, I get that it would be bad, but as you point out you already fail early on union branches
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
well, as a user, that also makes sense ... I know it's a runtime performance hit but the behavior makes intuitive sense
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
I understand why it's happening but it's confusing as a user to have types not be independent of each other in terms of behavior
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
I dunno
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
hmmmm. yeah this is real tricky
188 replies
Aarktype
•Created by Stuart B on 9/25/2024 in #questions
Post-morph constraints not checked if constraints not met on another property
ah, right, of course, in this case
.parse
is the morph?188 replies