Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ see [architecture.md](architecture.md#information-flow) for that flow.

`ValidationResult.ruleViolations` carries each violation's effective `severity` (`error`, `warning` or `info`). Only `error` severity violations should be treated as failures.

`nodeIssues(result)` gathers every result about a node into one map per node: schema, duplicate id, broken link, hierarchy, rule, gated and unresolved content link issues, each keyed by a composite id such as `rule:<id>` and carrying its `kind`, `message` and `severity`. Read `severity` rather than deriving it from `kind`. Pass `{ includeGated }` as validation ran, so a gated node's note says whether its rules were evaluated. Rule violations without a node and parse issues stay in their own parts of the result. `validateFile` returns one node's map as `issues`.
`nodeIssues(result)` gathers every result about a node into one map per node: schema, duplicate id, broken link, hierarchy, rule, gated and unresolved content link issues, each keyed by a composite id such as `rule:<id>` and carrying its `kind`, `message` and `severity`. `kind` is a `ValidationIssueKind`, and `VALIDATION_ISSUE_KINDS` lists every kind at runtime. Read `severity` rather than deriving it from `kind`. Pass `{ includeGated }` as validation ran, so a gated node's note says whether its rules were evaluated. Rule violations without a node and parse issues stay in their own parts of the result. `validateFile` returns one node's map as `issues`.

Each `ValidationResult` entry about a node carries its `nodeId`, and, where the entry is tied to a location, an optional `source` (`{ file, line?, column? }`). `duplicateErrors` lists a `sources` location for each node that shares the `id`. See [Validation results and nodes](concepts.md#validation-results-and-nodes).

Expand Down
2 changes: 2 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export type {
SpaceContext,
UnresolvedRef,
ValidateFileOutput,
ValidationIssueKind,
} from './types';
export { VALIDATION_ISSUE_KINDS } from './types';
export type { ValidationResult } from './validate';
export { nodeIssues, validateFile, validateSpace } from './validate';
17 changes: 15 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,22 @@ export type SpaceContext = {
configDir: string;
};

/** The checks a validation issue can come from. */
export const VALIDATION_ISSUE_KINDS = [
'schema',
'duplicate',
'broken-link',
'hierarchy',
'rule',
'gated',
'content-link',
] as const;

export type ValidationIssueKind = (typeof VALIDATION_ISSUE_KINDS)[number];

export interface FileValidationIssue {
/** The check it came from: `schema`, `duplicate`, `broken-link`, `hierarchy`, `rule`, `gated` or `content-link`. */
kind: string;
/** The check it came from. */
kind: ValidationIssueKind;
message: string;
/** How serious the issue is; consumers read it rather than infer it from `kind`. */
severity: RuleSeverity;
Expand Down
Loading