Skip to content

PolicyHandler

PolicyHandler<C> = ((args) => Promise<PolicyHandlerResult>) | ((args) => Operation<PolicyHandlerResult>)

Defined in: policy.ts:239

A policy handler function that checks a file against a policy.

C = unknown | undefined

Policy handlers can be implemented in two ways:

  • As an async function returning a Promise
  • As an Effection generator function returning an Operation

Both styles are supported. Async handlers are automatically wrapped for Effection.

Handlers can return either the legacy format (PolicyFailure) or the new format (PolicyError). The new format is simpler and recommended for new policies.