Seeking Guidance on Decoding Inside a Transform in Effect Typescript

Anyone willing to point me in the right direction? I'm currently decoding inside a transform, but this feels wrong. I'm not sure of how else I'd do this.
const registerSchema = Schema.transformOrFail(
  FormDataSchema,
  AccountDataSchema,
  {
    strict: true,
    decode: (formData) => Effect.succeed(Schema.decodeSync(AccountDataSchema)(formData)),
    encode: (accountData) =>
      Effect.succeed(
        Schema.decodeSync(FormDataSchema)(
          Object.assign(accountData, {
            confirmPassword: accountData.password
          })
        )
      )
  }
)

This code is to provide a schema validation layer for a signup form, this code currently will run on the server but I'll create a client layer later. If you notice any other mistakes I'm making, please let me know too! Here's the playground: https://effect.website/play/#c99a2ed421ed
Was this page helpful?