Function: hasContext()
Documentation / @xmachines/play-xstate / hasContext
function hasContext<TContext>(path): Guard<TContext, PlayEvent>;Defined in: packages/play-xstate/src/guards/helpers.ts:23
Check if context has a truthy value at path
Per CONTEXT.md: Convenience helper for common guard pattern
Type Parameters
| Type Parameter | Default type |
|---|---|
TContext | Record<string, unknown> |
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Dot-separated path to context property |
Returns
Guard predicate checking if property is truthy
Example
const machine = setup({ guards: { hasUserId: hasContext("userId"), hasEmail: hasContext("user.email"), },});