Skip to content

PURISTA API


PURISTA API / @purista/core / getCommandFunctionWithValidation

Function: getCommandFunctionWithValidation()

getCommandFunctionWithValidation<S>(fn, inputPayloadSchema, inputParameterSchema, outputPayloadSchema, beforeGuards): (this, context, payload, parameter) => Promise<unknown>

Defined in: CommandDefinitionBuilder/getCommandFunctionWithValidation.impl.ts:16

Wraps a command handler with schema validation and guard execution. Input payload/parameter is validated before execution and output can be validated after execution.

Type Parameters

S

S extends Service<ServiceClassTypes<any, any, any>>

Parameters

fn

CommandFunction<S, unknown, unknown, unknown, unknown, unknown, any, any, any, any, any>

inputPayloadSchema

Schema | undefined

inputParameterSchema

Schema | undefined

outputPayloadSchema

Schema | undefined

beforeGuards

Record<string, CommandBeforeGuardHook<S, unknown, unknown, unknown, unknown, any, any, any, any, any>>

Returns

(this, context, payload, parameter) => Promise<unknown>