validateLixSchema(
schema:unknown,data:unknown):boolean
Validates that a schema conforms to the LixSchemaDefinition format and then validates data against that schema.
const userSchema = {
"x-lix-key": "user",
"x-lix-version": "1.0",
type: "object",
properties: {
id: { type: "string" },
name: { type: "string" },
age: { type: "number" }
},
required: ["id", "name"]
} as const satisfies LixSchemaDefinition;
const userData = {
id: "123",
name: "John Doe",
age: 30
};
try {
validateLixSchema(userSchema, userData); // returns true
} catch (error) {
console.error("Validation failed:", error);
}| Parameter | Type | Description |
|---|---|---|
schema | unknown | The Lix schema definition to validate against |
data | unknown | The data to validate |
boolean
true if both the schema and data are valid
Error with validation details if either validation fails