🚨 Announcing Vendure v2 Beta

createErrorResultGuard

createErrorResultGuard

Convenience method for creating an ErrorResultGuard. Takes a predicate function which tests whether the input is considered successful (true) or an error result (false).

Note that the resulting variable must still be type annotated in order for the TypeScript type inference to work as expected:

Example

const orderResultGuard: ErrorResultGuard<AddItemToOrderResult>
  = createErrorResultGuard(order => !!order.lines);

Signature

function createErrorResultGuard<T>(testFn: (input: T) => boolean): ErrorResultGuard<T>

Parameters

testFn

parameter
type:
(input: T) => boolean