Documentation / @facturometro/einvoice / createRuleContext
Function: createRuleContext() ​
createRuleContext(
view,options?):RuleContext
Defined in: packages/validator/src/engine/context.ts:385
Builds the rule context of a document.
Parameters ​
view ​
The document view.
options? ​
What the caller knows beyond the document.
diagnostics? ​
readonly Issue[]
The parser diagnostics of the document; none by default.
Returns ​
The context.
Example ​
ts
import { createDocumentView, createRuleContext } from '@facturometro/validator';
const ctx = createRuleContext(createDocumentView(invoice));
ctx.country.supplier; // 'GB'
createRuleContext(createDocumentView(parsed.document), { diagnostics: parsed.diagnostics })
.diagnostics.length; // as many as the parser reported