Skip to content

createStaticValidatedMap()

Constructs a StaticValidatedMap from a collection of DecisionInput immediately applying all validations via the provided DecisionValidator.

type createStaticValidatedMap = (
context: StoreContext,
loadedRecords: LoadedRecord[],
validator?: DecisionValidator,
) => StaticValidatedMap;

Return value

Returns a StaticValidatedMap that can be used to query for ValidatedRecord and retrieve validation errors.

Params

context: StoreContext

A context object that exposes the StoreOptions and collects eventual errors produced building the store.

Params

loadedRecords: LoadedRecord[]

An array of loaded records as provided by loadDecisionsFromSources().

validator: DecisionValidator

An optional validator.

If no validator is provided, data is assumed to be valid. This is useful in scenarios where the data is guaranteed to have been validated in a different process.

Usage

The following snippet is taken from the staticStoreBuilder() implementation.

const context = createStoreContext(options);
const schemaMap = await loadSchemasFromSources(context);
const validator = createDecisionValidator(context, schemaMap);
const loadedRecords = await loadDecisionsFromSources(context);
const validatedMap = createStaticValidatedMap(context, loadedRecords, validator);
const store = createStaticStore(context, validatedMap);

Refer

See also