Effect CommunityEC
Effect Communityโ€ข2y agoโ€ข
76 replies
BinaryArtifex

Creating an Enhanced Error Handling for React-Hook-Form Resolver with Effect Schemas

gday folks so ive just finished up an initial version of an effect react-hook-form resolver using effect schemas and had a question regarding the generated error messages...taking this for example

export const SampleFormSchema = Schema.struct({
  quantity: Schema.Positive.pipe(
    Schema.message(() => "A postive value is required."),
    Schema.greaterThan(50, { message: () => "Must be greater than 50" }),
  ),
});


if i wanted better comprehensive error handling would i need to do away with the Positive constructor and pipe through the primitive types each with their own message? ie. number => positive => int each with their own piped messages?
Was this page helpful?