Home / Function/ getTypeOrLiteralMsg() — astro Function Reference

getTypeOrLiteralMsg() — astro Function Reference

Architecture documentation for the getTypeOrLiteralMsg() function in zod-error-map.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  c4289dde_e80c_3ee3_26bf_34ab19c7c1e0["getTypeOrLiteralMsg()"]
  c4702bad_5cd3_4ff4_dfb3_9107bd3ef578["zod-error-map.ts"]
  c4289dde_e80c_3ee3_26bf_34ab19c7c1e0 -->|defined in| c4702bad_5cd3_4ff4_dfb3_9107bd3ef578
  0518bc8c_7d4c_5826_2e65_b4a7da62d4f9["errorMap()"]
  0518bc8c_7d4c_5826_2e65_b4a7da62d4f9 -->|calls| c4289dde_e80c_3ee3_26bf_34ab19c7c1e0
  195ae4f8_5ad1_28c2_a579_82ad38b03171["unionExpectedVals()"]
  c4289dde_e80c_3ee3_26bf_34ab19c7c1e0 -->|calls| 195ae4f8_5ad1_28c2_a579_82ad38b03171
  ec2e794d_f0eb_1031_50b3_9bed5804ebc8["stringify()"]
  c4289dde_e80c_3ee3_26bf_34ab19c7c1e0 -->|calls| ec2e794d_f0eb_1031_50b3_9bed5804ebc8
  style c4289dde_e80c_3ee3_26bf_34ab19c7c1e0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/errors/zod-error-map.ts lines 104–119

const getTypeOrLiteralMsg = (error: TypeOrLiteralErrByPathEntry): string => {
	// received could be `undefined` or the string `'undefined'`
	if (typeof error.received === 'undefined' || error.received === 'undefined')
		return error.message ?? 'Required';
	const expectedDeduped = new Set(error.expected);
	switch (error.code) {
		case 'invalid_type':
			return `Expected type \`${unionExpectedVals(expectedDeduped)}\`, received \`${stringify(
				error.received,
			)}\``;
		case 'invalid_literal':
			return `Expected \`${unionExpectedVals(expectedDeduped)}\`, received \`${stringify(
				error.received,
			)}\``;
	}
};

Domain

Subdomains

Called By

Frequently Asked Questions

What does getTypeOrLiteralMsg() do?
getTypeOrLiteralMsg() is a function in the astro codebase, defined in packages/astro/src/core/errors/zod-error-map.ts.
Where is getTypeOrLiteralMsg() defined?
getTypeOrLiteralMsg() is defined in packages/astro/src/core/errors/zod-error-map.ts at line 104.
What does getTypeOrLiteralMsg() call?
getTypeOrLiteralMsg() calls 2 function(s): stringify, unionExpectedVals.
What calls getTypeOrLiteralMsg()?
getTypeOrLiteralMsg() is called by 1 function(s): errorMap.

Analyze Your Own Codebase

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

Try Supermodel Free