Skip to content

Validation

Without validation, data quality issues are discovered weeks later when a funnel breaks, a report shows $0 revenue, or a destination silently drops malformed events. Junction catches these at the source.

Define contracts per entity+action pair using Zod:

import { z } from "zod";
const schemas = {
"product:added": {
version: "1.0.0",
mode: "strict",
schema: z.object({
product_id: z.string().min(1),
name: z.string().min(1),
price: z.number().nonnegative(),
currency: z.string().length(3),
quantity: z.number().int().positive(),
}),
},
};
ModeInvalid Event Behavior
strictEvent is dropped, error logged
lenientWarning logged, event passes through

Use strict for critical events (purchases, sign-ups) and lenient during development or for non-critical events.

ScenarioWithout ValidationWith Junction
addToCart instead of product:addedFunnel breaks silentlyType error + runtime validation
Price sent as string "19.99"Destination coerces unpredictablyZod catches it
Missing product_idGA4 event fires without item_idContract rejects, logged
New dev forgets currency fieldRevenue reports show $0Strict mode blocks the event
import { createClient } from "@junctionjs/client";
const jct = createClient({
schemas,
destinations: [/* ... */],
});

Events without a matching contract pass through unvalidated. Add contracts incrementally — start with your most critical events.