Home / Function/ expectSchemaShape() — drizzle-orm Function Reference

expectSchemaShape() — drizzle-orm Function Reference

Architecture documentation for the expectSchemaShape() function in utils.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  2a85cab2_0338_353c_a5f7_46964a1b85f9["expectSchemaShape()"]
  b6483f8f_39d9_6c02_34b8_9a3df7d428eb["utils.ts"]
  2a85cab2_0338_353c_a5f7_46964a1b85f9 -->|defined in| b6483f8f_39d9_6c02_34b8_9a3df7d428eb
  5b37c583_4b51_6483_c764_098bfb14a603["onlySpecifiedKeys()"]
  2a85cab2_0338_353c_a5f7_46964a1b85f9 -->|calls| 5b37c583_4b51_6483_c764_098bfb14a603
  style 2a85cab2_0338_353c_a5f7_46964a1b85f9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-valibot/tests/utils.ts lines 8–33

export function expectSchemaShape<T extends v.ObjectSchema<v.ObjectEntries, undefined>>(t: TaskContext, expected: T) {
	return {
		from(actual: T) {
			expect(Object.keys(actual.entries)).toStrictEqual(Object.keys(expected.entries));

			for (const key of Object.keys(actual.entries)) {
				const actualEntry = actual.entries[key] as any;
				const expectedEntry = expected.entries[key] as any;
				const keys = ['kind', 'type', 'expects', 'async', 'message'];
				actualEntry.pipe ??= [];
				expectedEntry.pipe ??= [];

				expect(onlySpecifiedKeys(actualEntry, keys)).toStrictEqual(onlySpecifiedKeys(expectedEntry, keys));
				expect(actualEntry.pipe.length).toStrictEqual(expectedEntry.pipe.length);

				for (let i = 0; i < actualEntry.pipe.length; i++) {
					const actualPipeElement = actualEntry.pipe[i];
					const expectedPipeElement = expectedEntry.pipe[i];
					expect(onlySpecifiedKeys(actualPipeElement, keys)).toStrictEqual(
						onlySpecifiedKeys(expectedPipeElement, keys),
					);
				}
			}
		},
	};
}

Domain

Subdomains

Frequently Asked Questions

What does expectSchemaShape() do?
expectSchemaShape() is a function in the drizzle-orm codebase, defined in drizzle-valibot/tests/utils.ts.
Where is expectSchemaShape() defined?
expectSchemaShape() is defined in drizzle-valibot/tests/utils.ts at line 8.
What does expectSchemaShape() call?
expectSchemaShape() calls 1 function(s): onlySpecifiedKeys.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free