Customizing "is missing" error messages in Effect schema validation

Hey, I'm writing a library for combining Next.js & Effect. I have code that checks FormData against a schema, and adds errors to the object if there are schema errors.

Here's my example schema:
const CreateApiKey = S.Struct({
  name: S.String.pipe(
    S.minLength(3, { message: () => "Your API key name must be at least 3 characters." }),
    S.maxLength(32, { message: () => "Why would you need an API key name that long?" }),
  ),
})


As Giulio suggested, I'm using the ParseResult.ArrayFormatter.formatErrorSync(e); function to extract the errors. However, if a key is missing, I get:

{
  path: ["name"],
  message: "is missing"
}


So my question is, how can I change the "is missing" to something more user-friendly? (Eg. "Please provide a name for your API key")
Was this page helpful?