# Function createStateGuard

- createStateGuard(
  name: string,
  predicate: (state: Readonly<GraphState>) => boolean,
  errorMessage: string,
  ): PreconditionConfig

  Creates a precondition that checks state field values. Useful for enforcing invariants before node execution.

  #### Parameters

  - name: string
  - predicate: (state: Readonly<GraphState>) => boolean
  - errorMessage: string

  #### Returns PreconditionConfig

  - Defined in packages/nexus-agents/src/orchestration/graph/graph-hooks.ts:169