arktypea
arktype17mo ago
PIat

Extract type from or

Hello! Is it possible, using the following schema:
const userType = type({
    intent: "'profile'",
    name: 'string>0',
    surname: 'string>4',
})
.or({
    intent: "'private'",
    password: 'string>0',
})


to extract one of the types ("find" it by the intent field)? I'd like to use it for multiple forms on a page.

It's possible to split it into multiple types, but having it in one type is more readable to me
Was this page helpful?