Effect CommunityEC
Effect Community3y ago
19 replies
Dimitris

Unexpected email and age: Error in Formatted Message

What's the best way to get a nice formatted message from the errors?
import * as S from "@effect/schema/Schema";

const Person = S.struct({
  name: S.string,
  age: S.number
});

S.parseSync(Person)(
  {
    name: "Bob",
    age: "abc",
    email: "bob@example.com"
  },
  { errors: "all", onExcessProperty: "error" }
);
/*
throws
Error: error(s) found
├─ ["email"]
│  └─ is unexpected
└─ ["age"]
   └─ Expected number, actual "abc"
*/

Something like "email: is unexpected"
Was this page helpful?