Documentation / @facturometro/einvoice / RuleFactory
Interface: RuleFactory() ​
Defined in: packages/validator/src/engine/rule.ts:198
The two rule constructors: rule(id, definition) for specification rules and rule.custom(id, definition) for rules with inline metadata.
Example ​
import type { RuleFactory } from '@facturometro/validator';
const build = (factory: RuleFactory) => factory('BR-02', { at: 'document', test: (d) => d.id !== undefined });Call Signature ​
RuleFactory<
K>(id,definition):Rule<DocumentPaths[K]>
Defined in: packages/validator/src/engine/rule.ts:206
Builds a specification rule anchored at a DocumentPaths key.
Type Parameters ​
K ​
K extends keyof DocumentPaths
Parameters ​
id ​
A rule id of the pinned specification.
definition ​
The gate, anchor and test.
Returns ​
Rule<DocumentPaths[K]>
The rule.
Call Signature ​
RuleFactory<
N>(id,definition):Rule<N>
Defined in: packages/validator/src/engine/rule.ts:217
Builds a specification rule with a selector function as context.
Type Parameters ​
N ​
N
Parameters ​
id ​
A rule id of the pinned specification.
definition ​
The gate, selector and test.
Returns ​
Rule<N>
The rule.
Properties ​
custom ​
readonlycustom: {<K>(id,definition):Rule<DocumentPaths[K]>; <N>(id,definition):Rule<N>; }
Defined in: packages/validator/src/engine/rule.ts:219
Builds a rule with inline metadata; the id must not belong to the specification.
Call Signature ​
<
K>(id,definition):Rule<DocumentPaths[K]>
Builds a custom rule anchored at a DocumentPaths key.
Type Parameters ​
K ​
K extends keyof DocumentPaths
Parameters ​
id ​
string
The rule id.
definition ​
AtRuleDefinition<K> & CustomRuleMetadata
The metadata, gate, anchor and test.
Returns ​
Rule<DocumentPaths[K]>
The rule.
Call Signature ​
<
N>(id,definition):Rule<N>
Builds a custom rule with a selector function as context.
Type Parameters ​
N ​
N
Parameters ​
id ​
string
The rule id.
definition ​
ContextRuleDefinition<N> & CustomRuleMetadata
The metadata, gate, selector and test.
Returns ​
Rule<N>
The rule.