Skip to content

Commit 2052114

Browse files
feat: add validator run event to allow plugins to perform custom validation
1 parent 04abc19 commit 2052114

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export {
2828
} from "./lib/output";
2929
export type { RenderTemplate, RendererHooks } from "./lib/output";
3030

31+
export { Validator } from "./lib/validation";
32+
3133
export {
3234
ArgumentsReader,
3335
BindOption,

src/lib/validation/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Validator } from "./validator";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const ValidatorEvents = {
2+
RUN: "run_validator",
3+
} as const;

src/lib/validation/validator.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ValidatorComponent } from "./components";
66
import { validateExports } from "./exports";
77
import { validateDocumentation } from "./documentation";
88
import { validateLinks } from "./links";
9+
import { ValidatorEvents } from "./validator-events";
910

1011
@Component({
1112
name: "validator",
@@ -16,6 +17,17 @@ export class Validator extends ChildableComponent<
1617
Application,
1718
ValidatorComponent
1819
> {
20+
/**
21+
* General events
22+
*/
23+
24+
/**
25+
* Triggered when the converter begins converting a project.
26+
* The listener will be given a {@link Context} object.
27+
* @event
28+
*/
29+
static readonly EVENT_RUN = ValidatorEvents.RUN;
30+
1931
constructor(owner: Application) {
2032
super(owner);
2133
}
@@ -44,6 +56,8 @@ export class Validator extends ChildableComponent<
4456
validateLinks(project, this.application.logger);
4557
}
4658

59+
this.trigger(Validator.EVENT_RUN, project);
60+
4761
this.application.logger.verbose(
4862
`Validation took ${Date.now() - start}ms`
4963
);

0 commit comments

Comments
 (0)