Custom Error Messages in Effect Schema Not Displaying

I'm trying to get custom error messages from Effect Schema, but somehow only the default errors are returned. This is my schema:
const User = Schema.Struct({
  email: Schema.String.pipe(
    Schema.nonEmptyString({ message: () => ({ message: 'Email is required', override: true }) }),
  ),
  password: Schema.String.pipe(
    Schema.nonEmptyString({ message: () => ({ message: 'Password is required', override: true }) }),
  ),
  firstname: Schema.String.pipe(
    Schema.nonEmptyString({
      message: () => ({ message: 'First name is required', override: true }),
    }),
  ),
  lastname: Schema.String.pipe(
    Schema.nonEmptyString({
      message: () => ({ message: 'Last name is required', override: true }),
    }),
  ),
})

I also tried with Schema.String.annotation, but that didn't work either.
const submittedData = Object.fromEntries(formData)
  const decodedData = Schema.decodeUnknownEither(User, { errors: 'all' })(submittedData)
  if (Either.isLeft(decodedData)) {
    const errors = ParseResult.ArrayFormatter.formatErrorSync(decodedData.left).map((issue) => [
      issue.path[0],
      issue.message,
    ])

Can someone give me a hint?
Was this page helpful?