Custom error message for missing key in schema definition

Is it possible to provide a custom error message when a key is missing? The message "Missing key or index".

For when tags is entirely missing. I would like to provide a custom message for that.

export const FormSchema = S.struct({
  tags: S.array(S.string).pipe(
    S.message(() => "Tags are required"),
    S.minItems(1, { message: () => "Min items" }),
    S.maxItems(2, { message: () => "Max items" }),
  ),
});
Was this page helpful?