Documentation / @facturometro/einvoice / RulesetDefinition
Interface: RulesetDefinition ​
Defined in: packages/validator/src/rulesets/define.ts:54
What defineRuleset() takes.
Example ​
import type { RulesetDefinition } from '@facturometro/validator';
const definition: RulesetDefinition = { id: 'acme', requires: [peppolRuleset], version: '1.0.0' };Properties ​
disable? ​
readonlyoptionaldisable?: readonlystring[]
Defined in: packages/validator/src/rulesets/define.ts:65
Rule ids or globs (BR-CO-*, UBL-CR-*) to remove; they match rules defined by constants earlier in the list and the structural ids (UBL-CR-*, UBL-SR-*, UBL-DT-*) of the base layer that precedes every composition, and each entry must match at least one that is not already disabled. A disabled id is gone for every later constant, and disabling cannot be undone: a later override of it throws, and so does a later constant defining the same id again. To replace a rule, list it in override instead. An entry that can match one of the library's own EINV- ids (EINV-XML-EMPTY, EINV-*, *) throws: those report data the library could not read or check.
id ​
readonlyid:string
Defined in: packages/validator/src/rulesets/define.ts:67
Ruleset id, e.g. peppol or acme; reported as definedBy on the issues of its rules.
normalize? ​
readonlyoptionalnormalize?:Normalizer
Defined in: packages/validator/src/rulesets/define.ts:69
Defaults hook, run before validation; the hooks of a composition run in list order.
override? ​
readonlyoptionaloverride?:Readonly<Record<string,Partial<Pick<Rule<unknown>,"message"|"severity"|"context"|"test"|"when">>>>
Defined in: packages/validator/src/rulesets/define.ts:79
Patches to rules defined by constants earlier in the list, or to structural ids of the base layer, by id; each must exist there and not be disabled. When two constants patch the same field, the later one in the list wins. Patches apply unconditionally, whatever this constant's when, and never remove or replace the gate of the constant that defined the rule. A structural rule that the parser checks takes only severity and message (validateXml() applies them to its diagnostics); test, when or context on one throws, and so does an EINV- id.
requires? ​
readonlyoptionalrequires?: readonlyRuleset[]
Defined in: packages/validator/src/rulesets/define.ts:81
Rulesets that must appear earlier in every list this one is in.
rules? ​
readonlyoptionalrules?: readonlyRule<unknown>[]
Defined in: packages/validator/src/rulesets/define.ts:87
The rules. An id already defined by a constant earlier in the list is an error unless it is also listed in override, in which case this rule replaces the earlier one, in the earlier one's position, gated by the earlier constant's when AND this one's.
spec? ​
readonlyoptionalspec?:Readonly<Record<string,string>>
Defined in: packages/validator/src/rulesets/define.ts:89
The specification versions the ruleset implements, for reports and documentation.
version ​
readonlyversion:string
Defined in: packages/validator/src/rulesets/define.ts:91
Ruleset version, e.g. 3.0.21.
when? ​
readonlyoptionalwhen?: (ctx) =>boolean
Defined in: packages/validator/src/rulesets/define.ts:102
Document-level gate AND-ed into every one of this constant's own rules, e.g. the Danish supplier check of dkRuleset; a replacement keeps the replaced rule's gate and adds this one. It does not gate disable or override, which apply unconditionally, and no later override removes it: override.when replaces only a rule's own when, never a ruleset gate.
Parameters ​
ctx ​
The rule context.
Returns ​
boolean
Whether the ruleset applies to the document.