Documentation / @einvoice-ts/validator / 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:406
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 option is not a list of ruleset constants or its composition does not compile; see validate() for every case.
Example ​
import { assertValid } from '@einvoice-ts/validator';
const invoice = assertValid(parsed.document); // InvoiceCall Signature ​
assertValid(
document,options?):CreditNote
Defined in: packages/validator/src/engine/validate.ts:417
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:428
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.