Skip to content

Documentation / @facturometro/validator / LexicalError

Class: LexicalError ​

Defined in: packages/validator/src/engine/issue.ts:93

What a cast throws for a value outside its lexical space: ctx.dec() and ctx.sum() for a decimal, the xs:date helpers for a date, and the document view's allowance and charge selectors under { unreadable: 'throw' } for a cbc:ChargeIndicator. That is what makes a rule dependent on the value: when the value (in that lexical space) is one the pre-pass reported, the engine skips the context node whose test threw, or the whole rule when its gate or context selection threw, so the rule neither fails nor crashes. A lexical error about any other value is a rule error, as it means the rule cast something the schema does not type that way.

Built-in rules only cast in their tests, so a bad value costs one node, never a whole rule. Selecting allowances and charges as a context does not cast: by default the view leaves an unreadable indicator's node out (per node, like a test skip), and only the rules that sum a selection (BR-CO-11/12, PEPPOL-EN16931-R120, the BR-*-08 VAT sums) ask it to throw.

Example ​

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

throw new LexicalError('-1E2', 'xs:decimal');

Extends ​

  • Error

Constructors ​

Constructor ​

new LexicalError(value, expected): LexicalError

Defined in: packages/validator/src/engine/issue.ts:105

Builds the error.

Parameters ​

value ​

string

The value, exactly as it appears in the document.

expected ​

LexicalSpace

The lexical space it is not in.

Returns ​

LexicalError

Overrides ​

Error.constructor

Properties ​

cause? ​

optional cause?: unknown

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from ​

Error.cause


expected ​

readonly expected: LexicalSpace

Defined in: packages/validator/src/engine/issue.ts:95

The lexical space the value is not in.


message ​

message: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from ​

Error.message


name ​

name: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074

Inherited from ​

Error.name


stack? ​

optional stack?: string

Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from ​

Error.stack


value ​

readonly value: string

Defined in: packages/validator/src/engine/issue.ts:97

The value, exactly as it appears in the document.

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