Skip to content

Commit

Permalink
feat: add validator run event to allow plugins to perform custom vali…
Browse files Browse the repository at this point in the history
…dation
  • Loading branch information
RebeccaStevens committed Feb 24, 2023
1 parent 04abc19 commit 2052114
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Expand Up @@ -28,6 +28,8 @@ export {
} from "./lib/output";
export type { RenderTemplate, RendererHooks } from "./lib/output";

export { Validator } from "./lib/validation";

export {
ArgumentsReader,
BindOption,
Expand Down
1 change: 1 addition & 0 deletions src/lib/validation/index.ts
@@ -0,0 +1 @@
export { Validator } from "./validator";
3 changes: 3 additions & 0 deletions src/lib/validation/validator-events.ts
@@ -0,0 +1,3 @@
export const ValidatorEvents = {
RUN: "run_validator",
} as const;
14 changes: 14 additions & 0 deletions src/lib/validation/validator.ts
Expand Up @@ -6,6 +6,7 @@ import { ValidatorComponent } from "./components";
import { validateExports } from "./exports";
import { validateDocumentation } from "./documentation";
import { validateLinks } from "./links";
import { ValidatorEvents } from "./validator-events";

@Component({
name: "validator",
Expand All @@ -16,6 +17,17 @@ export class Validator extends ChildableComponent<
Application,
ValidatorComponent
> {
/**
* General events
*/

/**
* Triggered when the converter begins converting a project.
* The listener will be given a {@link Context} object.
* @event
*/
static readonly EVENT_RUN = ValidatorEvents.RUN;

constructor(owner: Application) {
super(owner);
}
Expand Down Expand Up @@ -44,6 +56,8 @@ export class Validator extends ChildableComponent<
validateLinks(project, this.application.logger);
}

this.trigger(Validator.EVENT_RUN, project);

this.application.logger.verbose(
`Validation took ${Date.now() - start}ms`
);
Expand Down

0 comments on commit 2052114

Please sign in to comment.