Repository navigation
Closed
Description
import { type } from "arktype";
const Thing = type("string.email > 0").configure({
message: "Email is not valid",
});
// standard bulleted message- config seemingly not applied
const out = Thing("");This doesn't work because an intersection error is built from a dynamic list of failures, so metadata from the node is never applied to the error.
Workaround:
Configure intersection errors globally or at a scope-level:
const { type } = scope(
{},
{
intersection: {
message: (ctx) => {
if (
ctx.flat.every(
(e, i) =>
i === ctx.flat.length - 1 || e.message === ctx.flat[i + 1].message
)
) {
return ctx.flat[0].message;
}
return ctx.problem;
},
},
}
);
const Thing = type("string.email > 0").configure({
message: "Email is not valid",
});
const out = Thing("");
// Email is not valid
console.log(out.summary);Reacted by ray-overjet
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone (merged or closed)
Activity
robin-blanchard commentedon Jul 16, 2025
Related: #1479
fix(schema): write constraints described alike once
fix(type): write constraints described alike once in de
feat(schema): surface a message every failing branch or constraint sh…
ssalbdivad commentedon Nov 18, 2026
Fixed in 3.0.0-beta.0 (#1728). Try it with
npm i arktype@next.