Effect CommunityEC
Effect Community2y ago
3 replies
Nanniiii

anyone has an idea on how to do that, i'

anyone has an idea on how to do that, i'm a bit stuck on this one :/

also looking into a different approach where i could defined a schema and later on extend the fields of that schema to make them optional.

const origin = S.Struct({ name: S.String, state: S.String.pipe(S.minLength(1), S.maxLength(23)) }) // { name:string; state: string }
const later = ...do something maybe something with extends or origin.fields? // { name?:string; state?: string }

tried this
const schema = S.Struct({
    ...Object.fromEntries(
        [...Object.entries(apiSchema.fields)].map(([key, value]) => [key, S.optional(value, { exact: true })]),
    ),
})


but i loose the types and makes my eyes bleed a bit too 😂
Was this page helpful?