diff --git a/ark/schema/roots/unit.ts b/ark/schema/roots/unit.ts index 76c0675966..35878b9f3b 100644 --- a/ark/schema/roots/unit.ts +++ b/ark/schema/roots/unit.ts @@ -48,7 +48,9 @@ export const unitImplementation: nodeImplementationOf = }, normalize: schema => schema, defaults: { - description: node => printable(node.unit) + description: node => printable(node.unit), + problem: ({ expected, actual }) => + `${expected === actual ? `must be reference equal to ${expected} (serialized to the same value)` : `must be ${expected} (was ${actual})`}` }, intersections: { unit: (l, r) => Disjoint.from("unit", l, r), diff --git a/ark/type/__tests__/objectLiteral.test.ts b/ark/type/__tests__/objectLiteral.test.ts index bf0f077931..be3843fb15 100644 --- a/ark/type/__tests__/objectLiteral.test.ts +++ b/ark/type/__tests__/objectLiteral.test.ts @@ -54,6 +54,13 @@ contextualize( }) }) + it("serializes to same value but not reference equal", () => { + const t = type("===", {}) + attest(t({}).toString()).snap( + "must be reference equal to {} (serialized to the same value)" + ) + }) + it("error in obj that has tuple that writes error at proper path", () => { // @ts-expect-error attest(() => type({ "a?": ["string", ["stringx", "?"]] }))