L0xus
Aarktype
•Created by L0xus on 3/16/2025 in #questions
Narrow type based on another property's value
Hey, I've been using ArkType for a few days now - loving it so far. One thing I'd love to be able to do is narrow a type based on the value of another property in the object. eg.
given this code, I would want the type of 'value' to change based on the 'type' property. if 'type ' is 'string', then I'd want value to be narrowed to 'string', but if 'type' is 'Color', I'd want it to be narrowed to 'string.hex'. Is there currently a way to do this in the ArkType system?
Many thanks in advance,
Chris
10 replies