Effect CommunityEC
Effect Community2y ago
4 replies
Stephen Bluck

Modifying Filter Messages in Reused Schemas

Let's say I have a schema like so:
export const Strong = S.String.pipe(
  S.minLength(8),
  S.maxLength(64),
  S.brand("StrongPassword")
);

And then somewhere else I want to use this schema but with a custom error message:
export const PasswordStrong = Strong.pipe(S.message(() => "Your password is too weak"));

This is all good but is there a way to modify the error message for each of the filters? I don't want to do it in the definition of Strong but rather where it is re-used. Not sure if it is possible?
Was this page helpful?