@domorium/validator 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to `@domorium/validator` are documented here.
4
4
 
5
+ ## 1.6.0 - 2026-08-12
6
+
7
+ - **A fragment can be checked without being told it is not a file.** Text that is
8
+ part of a document rather than one of its own — a block pasted into a note, an
9
+ example in documentation, a selection — was judged as a whole file, so the one
10
+ thing certainly not the author's mistake was the first thing reported, and
11
+ nothing after it was read at all. `createDocument(text, { fragment: true,
12
+ dialect })` reads the lines and goes quiet only about what the boundary caused:
13
+ the missing header and trailer, a pointer leaving the text, an extension tag
14
+ with no `HEAD.SCHMA` to declare it in. An unknown tag, a payload of the wrong
15
+ type and a level that cannot follow the line above are still reported.
16
+ - `dialect` is named by the caller because a fragment carries no
17
+ `HEAD.GEDC.VERS`; without one there are still no rules to read it by.
18
+
5
19
  ## 1.5.0 - 2026-08-10
6
20
 
7
21
  - **The GEDCOM version is resolved against a table by longest match, and a
package/README.md CHANGED
@@ -25,6 +25,23 @@ const document = new GedcomDocument().createDocument(gedcomString);
25
25
  const errors = document.getErrors();
26
26
  ```
27
27
 
28
+ ## Fragments
29
+
30
+ A fenced block in a note, an example in documentation, a selection: text that is
31
+ part of a document rather than one of its own.
32
+
33
+ ```typescript
34
+ const block = new GedcomDocument().createDocument(text, {
35
+ fragment: true,
36
+ dialect: "7.0",
37
+ });
38
+ ```
39
+
40
+ What goes quiet is what the boundary caused — the header and trailer, a pointer
41
+ leaving the text, an extension tag with no `HEAD.SCHMA` to declare it in.
42
+ Everything else is still read. `dialect` is needed because a fragment carries no
43
+ `HEAD.GEDC.VERS`.
44
+
28
45
  ## Diagnostics
29
46
 
30
47
  `getErrors()` returns `GedcomError[]`:
@@ -3,6 +3,12 @@ import { ASTNode, ASTToken } from "../parser";
3
3
  import { type GedcomDialect, type VersionResolution } from "../validator/versionRegistry";
4
4
  import { type GedcomCompletion } from "../completion/completion";
5
5
  import type { Position } from "../types/position";
6
+ export interface CreateDocumentOptions {
7
+ /** Text that is part of a document rather than one of its own. */
8
+ fragment?: boolean;
9
+ /** A fragment carries no header, so the rules are named rather than read. */
10
+ dialect?: GedcomDialect;
11
+ }
6
12
  export declare class GedcomDocument {
7
13
  private nodes;
8
14
  pointers: Map<string, ASTNode[]>;
@@ -13,7 +19,8 @@ export declare class GedcomDocument {
13
19
  private requiresSchmaDeclaration;
14
20
  private extensions;
15
21
  private parseGedcom;
16
- createDocument(text: string): GedcomDocument;
22
+ createDocument(text: string, options?: CreateDocumentOptions): GedcomDocument;
23
+ private applyScheme;
17
24
  private validateLevels;
18
25
  getLabel(node: ASTNode): string | undefined;
19
26
  getPointerTargetTag(node: ASTNode): string | undefined;