@domorium/validator 1.3.0 → 1.5.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 +76 -0
- package/README.md +48 -0
- package/dist/document/gedcomDocument.d.ts +5 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +654 -528
- package/dist/types/errors.d.ts +40 -0
- package/dist/validator/date-v7.d.ts +4 -3
- package/dist/validator/extensions.d.ts +7 -6
- package/dist/validator/index.d.ts +1 -1
- package/dist/validator/rule-node.d.ts +5 -5
- package/dist/validator/validate.d.ts +1 -0
- package/dist/validator/versionRegistry.d.ts +28 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@domorium/validator` are documented here.
|
|
4
4
|
|
|
5
|
+
## 1.5.0 - 2026-08-10
|
|
6
|
+
|
|
7
|
+
- **The GEDCOM version is resolved against a table by longest match, and a
|
|
8
|
+
version we hold no schema for no longer validates against the newest one.**
|
|
9
|
+
`2 VERS 4.0`, a garbage version and a document with no `VERS` line were all
|
|
10
|
+
checked against GEDCOM 7 and reported clean, because nothing they were checked
|
|
11
|
+
against applied to them. Three codes replace that silence: `VAL011` for a
|
|
12
|
+
version no schema describes, `VAL012` for a document whose version cannot be
|
|
13
|
+
read, `VAL013` for one checked against another version's schema. The first two
|
|
14
|
+
suppress every schema-derived diagnostic, while lexing, tree assembly and
|
|
15
|
+
level validation still run — a 4.0 file with a level that cannot follow the
|
|
16
|
+
line above it still says so. `5.5`, `5.5.5` and `5.5 EL` are checked against
|
|
17
|
+
the 5.5.1 schema with a warning naming the substitution; `5.6`, `5.4`, `5.3`,
|
|
18
|
+
`5.0` and `4` are not, because the difference runs the wrong way and the
|
|
19
|
+
substitution would report false errors on correct lines.
|
|
20
|
+
- **A structure the specification gives no substructures accepted any child.**
|
|
21
|
+
`getRules` answered `undefined` both for a leaf and for a type it could not
|
|
22
|
+
resolve, and the permissive reading of the two won: 57 structures in GEDCOM 7
|
|
23
|
+
and 89 in 5.5.1 accepted anything at all, `TRLR` among them in 5.5.1. So
|
|
24
|
+
|
|
25
|
+
0 @S1@ SOUR
|
|
26
|
+
1 TITL Open Archieven
|
|
27
|
+
2 BOGUS whatever
|
|
28
|
+
|
|
29
|
+
reported nothing. A child of a leaf structure is now an unknown tag.
|
|
30
|
+
|
|
31
|
+
- `2 VERS 5.5.1`, with more than one space after the tag, selected the GEDCOM 7
|
|
32
|
+
schema and the file came back clean. The delimiter after a tag belongs to the
|
|
33
|
+
payload, so the version is trimmed before it selects anything. Present since
|
|
34
|
+
1.2.0.
|
|
35
|
+
- The inline form of a 5.5.1 multimedia link was unreachable, so `1 OBJE` with
|
|
36
|
+
`FILE` and `TITL` written beneath it reported `FILE` as an unknown tag. Both
|
|
37
|
+
shapes now resolve. One type serves both, so a pointer carrying children and an
|
|
38
|
+
inline form with only a `TITL` are accepted where the specification allows
|
|
39
|
+
neither; telling them apart needs a schema that can offer two types for one
|
|
40
|
+
tag.
|
|
41
|
+
- New on `GedcomDocument`: `getVersionResolution()` returns the outcome above
|
|
42
|
+
without parsing a message, and `getDialect()` names the version whose rules
|
|
43
|
+
apply — or nothing, for a version we cannot judge. `VersionResolution` and
|
|
44
|
+
`GedcomDialect` are exported alongside them.
|
|
45
|
+
|
|
46
|
+
## 1.4.0 - 2026-08-09
|
|
47
|
+
|
|
48
|
+
- Read a `HEAD.SCHMA` tag whose URI is a standard one as the structure it names.
|
|
49
|
+
A tag definition makes its tag an abbreviation for that URI, so a record
|
|
50
|
+
written under an alias now answers a pointer to the standard tag, a date in an
|
|
51
|
+
aliased calendar carries that calendar's months, and an aliased structure is
|
|
52
|
+
validated as the standard one — payload and substructures alike. Its position
|
|
53
|
+
is not checked: a relocated standard structure may only appear under a
|
|
54
|
+
superstructure the specification does not document it under.
|
|
55
|
+
- Accept an extension tag as an enumeration value. Every one was reported as an
|
|
56
|
+
error, though the specification permits extending an enumeration with values
|
|
57
|
+
matching `extTag`. A value borrowed from another standard set, which the same
|
|
58
|
+
paragraph forbids, is still refused. An undocumented extension value reports
|
|
59
|
+
`VAL008`, as an undocumented tag already did.
|
|
60
|
+
- Stop requiring a payload GEDCOM 5.5.1 does not define. `1 EVEN` with a `TYPE`
|
|
61
|
+
beneath it was reported as missing a value; the individual event structure
|
|
62
|
+
gives it no payload at all, and the family one spells it
|
|
63
|
+
`[<EVENT_DESCRIPTOR> | <NULL>]`.
|
|
64
|
+
- **Reject a whole-number payload that is not a number.** `1 NCHI abc` was
|
|
65
|
+
accepted, and so were `3.7`, `12abc`, `1e3` and `Infinity`: the check compared
|
|
66
|
+
`parseInt(value) < 0`, and `NaN` fails every comparison.
|
|
67
|
+
- An event with neither a payload nor substructures is a warning, `VAL010`,
|
|
68
|
+
rather than an error reading "should be Y or null" — null is what it had, and
|
|
69
|
+
the payload is optional. It is not silent either: 5.5.1 introduces the `Y`
|
|
70
|
+
convention precisely to protect against processors that prune lines having
|
|
71
|
+
neither a value nor a subordinate line.
|
|
72
|
+
- A pointer whose target record type appears nowhere in the document no longer
|
|
73
|
+
reads `should be in set []`.
|
|
74
|
+
- **Each kind of problem now has its own code.** Every payload problem shipped as
|
|
75
|
+
the bare string `VAL`, so a consumer could not tell a missing value from a
|
|
76
|
+
malformed one, and `VAL003` to `VAL006` sat declared and unused. See the code
|
|
77
|
+
table in the README. `unresolved-xref` and `invalid-level` keep their strings.
|
|
78
|
+
- Export `GedcomError`, `GedcomErrorCode`, `Range` and `Position`. `getErrors()`
|
|
79
|
+
returns `GedcomError[]` and the type could not be named by a consumer.
|
|
80
|
+
|
|
5
81
|
## 1.3.0 - 2026-08-08
|
|
6
82
|
|
|
7
83
|
- Read GEDCOM 7 dates against the calendar they name. `JULIAN 1401`,
|
package/README.md
CHANGED
|
@@ -25,6 +25,54 @@ const document = new GedcomDocument().createDocument(gedcomString);
|
|
|
25
25
|
const errors = document.getErrors();
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Diagnostics
|
|
29
|
+
|
|
30
|
+
`getErrors()` returns `GedcomError[]`:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import type { GedcomError, Position, Range } from "@domorium/validator";
|
|
34
|
+
|
|
35
|
+
interface GedcomError {
|
|
36
|
+
code: string;
|
|
37
|
+
message: string;
|
|
38
|
+
hint?: string;
|
|
39
|
+
data?: { xref?: string; requiredRecordTag?: string; expectedLevel?: number };
|
|
40
|
+
range: Range;
|
|
41
|
+
level: "error" | "warning" | "info";
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`data` carries the facts a quick fix is built from — which xref failed to
|
|
46
|
+
resolve, and what record tag it needed.
|
|
47
|
+
|
|
48
|
+
Match on `code` rather than on `message`; messages are written for people and
|
|
49
|
+
change. `GedcomErrorCode` is exported for this:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { GedcomErrorCode } from "@domorium/validator";
|
|
53
|
+
|
|
54
|
+
const unresolved = errors.filter(
|
|
55
|
+
(error) => error.code === GedcomErrorCode.UnresolvedXref,
|
|
56
|
+
);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Code | Member | Reported when |
|
|
60
|
+
| ----------------- | ---------------------- | ----------------------------------------------------------- |
|
|
61
|
+
| `VAL001` | `UnknownTag` | a tag the schema does not define in this position |
|
|
62
|
+
| `VAL002` | `MissingTag` | a structure the schema requires is absent |
|
|
63
|
+
| `VAL003` | `MissingValue` | the payload is absent where one is required |
|
|
64
|
+
| `VAL004` | `IncorrectValue` | the payload does not match its data type |
|
|
65
|
+
| `VAL005` | `ShouldBeSetValue` | the payload is not one of the permitted values |
|
|
66
|
+
| `VAL006` | `MissingRef` | a pointer payload that is not written as a pointer |
|
|
67
|
+
| `VAL007` | `ManyOccurrences` | more occurrences than the cardinality allows |
|
|
68
|
+
| `VAL008` | `UndocumentedTag` | a GEDCOM 7 extension tag with no `HEAD`.`SCHMA` declaration |
|
|
69
|
+
| `VAL009` | `DuplicateDeclaration` | a tag declared more than once in `HEAD`.`SCHMA` |
|
|
70
|
+
| `VAL010` | `EmptyEvent` | an event with neither a payload nor substructures |
|
|
71
|
+
| `unresolved-xref` | `UnresolvedXref` | an xref naming no record of the required type |
|
|
72
|
+
| `invalid-level` | `InvalidLevel` | a level that cannot follow the line above it |
|
|
73
|
+
| `LEXER` | `Lexer` | the text could not be tokenized |
|
|
74
|
+
| `PARSER` | `Parser` | the tokens could not be assembled into a tree |
|
|
75
|
+
|
|
28
76
|
## Scripts
|
|
29
77
|
|
|
30
78
|
| Command | Description |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GedcomError } from "../types/errors";
|
|
2
2
|
import { ASTNode, ASTToken } from "../parser";
|
|
3
|
+
import { type GedcomDialect, type VersionResolution } from "../validator/versionRegistry";
|
|
3
4
|
import { type GedcomCompletion } from "../completion/completion";
|
|
4
5
|
import type { Position } from "../types/position";
|
|
5
6
|
export declare class GedcomDocument {
|
|
@@ -8,6 +9,8 @@ export declare class GedcomDocument {
|
|
|
8
9
|
xRefs: Map<string, ASTToken[]>;
|
|
9
10
|
private errors;
|
|
10
11
|
private scheme;
|
|
12
|
+
private resolution;
|
|
13
|
+
private requiresSchmaDeclaration;
|
|
11
14
|
private extensions;
|
|
12
15
|
private parseGedcom;
|
|
13
16
|
createDocument(text: string): GedcomDocument;
|
|
@@ -16,6 +19,8 @@ export declare class GedcomDocument {
|
|
|
16
19
|
getPointerTargetTag(node: ASTNode): string | undefined;
|
|
17
20
|
isRecordDeclaration(node: ASTNode): boolean;
|
|
18
21
|
getVersion(): string | undefined;
|
|
22
|
+
getVersionResolution(): VersionResolution | undefined;
|
|
23
|
+
getDialect(): GedcomDialect | undefined;
|
|
19
24
|
getCompletions(position: Position, lineText: string): GedcomCompletion[];
|
|
20
25
|
updateDocument(_text: string, _range: Range): GedcomDocument;
|
|
21
26
|
getErrors(_lang?: string): GedcomError[];
|