createRecordMap()
Constructs a RecordMap from a collection of DecisionInput immediately applying all validations via the provided DecisionValidator.
type createRecordMap = (loadedRecords: LoadedRecord[], validator?: DecisionValidator) => RecordMap;
Return value
Returns a RecordMap that can be used to query for ValidatedRecord and retrieve validation errors.
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 buildStaticStore() implementation.
const context = createBuilderContext(options);const schemaMap = await loadSchemasFromSources(context);const validator = createDecisionValidator(context, schemaMap);
const loadedRecords = await loadDecisionsFromSources(context);const validatedMap = createRecordMap(loadedRecords, validator);const store = createStore(validatedMap);