Effect CommunityEC
Effect Community•5mo ago
amg

Reusing Schema for Create and Update Operations in Effect Typescript

Hi 👋, I am trying to reuse a schema for create and update a record in the database
export const createFabricSchema = Schema.Struct({
    color: Schema.String,
    color_name: Schema.String,
    description: Schema.String,
    reference: Schema.String,
    id: Schema.Number,
    image: Schema.optional(imageSchema)
});

export const updateFabricSchema = Schema.extend(
    Schema.partial(createFabricSchema),
    Schema.Struct({
        id: Schema.Number // Required field
    })
);


This code seems not correct when I execute it. Any better option??
Was this page helpful?