Interface Rule<TInput, TOutput, TContext>

interface Rule<
    TInput,
    TOutput,
    TContext extends
        RuleContext<TInput, TOutput> = RuleContext<TInput, TOutput>,
> {
    run: (context: TContext) => TContext;
    runIf: (input: ReadonlyDeep<TInput>) => boolean;
}

Type Parameters

Properties

Properties

run: (context: TContext) => TContext

A pure function that runs rule logic and returns a new context by appending to the output array.

runIf: (input: ReadonlyDeep<TInput>) => boolean

Returns whether the rule should run or not.

Only the input and not the full context is passed to runIf. This prevents rules from relying on output, which may be appended to by previous rules by the time run is called.