Limitations of Custom Error Messages for Struct Schema in TypeScript

It seems like you can't define a custom error message for struct schema, but only for primitives:
const struct = pipe(
    Schema.struct({
        a: Schema.string,
        b: Schema.number
    }),
    Schema.message(() => `my error here`)
)
Schema.parse(struct)(`not the expected schema`)
// Expected a generic object, actual "not the expected schema"

const number = pipe(
    Schema.number,
    Schema.message(() => `my error here`)
)
Schema.parse(number)(`not the expected schema`)
// my error here

Both parsings fail, but only the second one has the expected message as error message.
Was this page helpful?