Skip to main content


Utility function for mergin two object schemas. If the two schemas have overlapping keys, the second schema will take precedence. If the two schemas have different unknownKeysBehaviors, the second schema's behavior will take precedence.


import { merge, object, string, tuple } from "@sodd/core";

const schema1 = object(
name: string(),
location: string(), // "City, Country"

const schema2 = object({
name: string(),
location: tuple([string(), string()]), // ["City", "Country"]

const mergedSchema = merge(schema1, schema2);

name: "Test McTestface",
location: ["Townville", "Countryland"],
age: 123,
}); // ✅ — `age` is discarded due to `schema2`'s implicit "strip" behavior