Creating a Partial Schema with Required ID in Effect Typescript

What is the best way to do the equivalent of

const requiredExceptId = z
  .object({
    id: z.string(),
    name: z.string(),
  })
  .partial()
  .required({ id: true })


something like this works but now I don't have a Struct anymore

const MySchema = Schema.Struct({
  id: Schema.String,
  name: Schema.String,
  email: Schema.String,
  age: Schema.Number,
})

const PartialExceptId = MySchema.pipe(
  Schema.omit('id'),
  Schema.partial,
  Schema.extend(MySchema.pipe(Schema.pick('id'))),
)
Was this page helpful?