Skip to content

Function: validateViewProps()

Documentation / @xmachines/play-xstate / validateViewProps

Implementation — shared by both overloads

Call Signature

function validateViewProps<TCatalog>(componentName, props, catalog): ValidationResult;

Defined in: packages/play-xstate/src/catalog/validate-props.ts:35

Validate view props against Zod schema — generic overload for typed catalogs

When called with a typed catalog, componentName is constrained to keyof TCatalog. Malformed catalog entries or unknown component names produce compile-time errors rather than runtime failures.

Type Parameters

Type ParameterDescription
TCatalog extends CatalogCatalog type (must extend Catalog)

Parameters

ParameterTypeDescription
componentNamekeyof TCatalog & stringComponent name constrained to string keys of TCatalog
propsunknownProps to validate
catalogTCatalogTyped component catalog

Returns

ValidationResult

Zod parse result

Call Signature

function validateViewProps(componentName, props, catalog): ValidationResult;

Defined in: packages/play-xstate/src/catalog/validate-props.ts:64

Validate view props against Zod schema — base overload for untyped catalogs

Per CONTEXT.md:

  • “Prop validation: At state entry”
  • “currentView derivation: Merge meta.view with relevant context data”

Per RESEARCH.md Pattern 4: Use safeParse() for validation

Parameters

ParameterTypeDescription
componentNamestringComponent name from catalog
propsunknownProps to validate
catalogCatalogComponent catalog with schemas

Returns

ValidationResult

Zod parse result

Example

const props = { userId: "123", stats: { logins: 5 } };
const result = validateViewProps("Dashboard", props, catalog);
if (!result.success) {
console.error(result.error);
}