Skip to content

Documentation / @facturometro/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:396

Validates a document and returns it, narrowed to its canonical type, or throws.

Parameters ​

document ​

Invoice | UncheckedInvoice

A parsed (Unchecked*) or built document.

options? ​

ValidateOptions

Which rulesets to run.

Returns ​

Invoice

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 ​

ts
import { assertValid } from '@facturometro/validator';

const invoice = assertValid(parsed.document); // Invoice

Call 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? ​

ValidateOptions

Which ruleset to run.

Returns ​

CreditNote

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 ​

Document | UncheckedDocument

A parsed or built document.

options? ​

ValidateOptions

Which ruleset to run.

Returns ​

Document

The validated document.

MIT licensed. Specification artefacts belong to OpenPEPPOL, CEN and OASIS.