Documentation / @facturometro/einvoice / assertValid
Function: assertValid() ​
The implementation behind the overloads.
Param ​
document
A parsed or built document.
Param ​
options
Which ruleset to run.
Call Signature ​
assertValid(
document,options?):Invoice
Defined in: packages/validator/src/engine/validate.ts:396
Validates a document and returns it, narrowed to its canonical type, or throws.
Parameters ​
document ​
A parsed (Unchecked*) or built document.
options? ​
Which rulesets to run.
Returns ​
The validated document, with the composition's defaults applied.
Throws ​
When a fatal issue is found; carries every issue and the ruleset.
Throws ​
When document.kind is neither Invoice nor CreditNote.
Throws ​
When the ruleset composition does not compile.
Example ​
import { assertValid } from '@facturometro/validator';
const invoice = assertValid(parsed.document); // InvoiceCall Signature ​
assertValid(
document,options?):CreditNote
Defined in: packages/validator/src/engine/validate.ts:407
Validates a credit note and returns it, or throws; see the invoice overload.
Parameters ​
document ​
CreditNote | UncheckedCreditNote
A parsed or built credit note.
options? ​
Which ruleset to run.
Returns ​
The validated credit note.
Call Signature ​
assertValid(
document,options?):Document
Defined in: packages/validator/src/engine/validate.ts:418
Validates a document of either kind and returns it, or throws; see the invoice overload.
Parameters ​
document ​
A parsed or built document.
options? ​
Which ruleset to run.
Returns ​
The validated document.