Luca Schultz
Luca Schultz
Aarktype
Created by Luca Schultz on 1/24/2025 in #questions
How to build generic functions that use ArkType schemas?
No description
65 replies
Aarktype
Created by Luca Schultz on 8/16/2024 in #questions
Is it possible to extract a "subtype"?
Hi, I'm looking into Arktype for the first time, so please forgive me if this is a noob question 😅 I wanna extract a "subtype"/"subschema" from a schema. I don't know how describe it better other than a code example:
const someScope = scope({
Endpoint: {
response: {
name: 'string',
age: 'number',
},
params: {
body: {
name: 'string',
age: 'number',
},
},
},
}).export()

const Endpoint = someScope.Endpoint

// Should be equivalent to type({ name: 'string', age: 'number' })
const Body = Endpoint.params.body
const someScope = scope({
Endpoint: {
response: {
name: 'string',
age: 'number',
},
params: {
body: {
name: 'string',
age: 'number',
},
},
},
}).export()

const Endpoint = someScope.Endpoint

// Should be equivalent to type({ name: 'string', age: 'number' })
const Body = Endpoint.params.body
11 replies