kist
Version:
Lightweight Package Pipeline Processor with Plugin Architecture
30 lines • 1.22 kB
JavaScript
import { AbstractValidator } from "../abstract/AbstractValidator.js";
import { ActionRegistry } from "../pipeline/ActionRegistry.js";
export class ActionValidator extends AbstractValidator {
constructor() {
super();
this.actionRegistry = ActionRegistry.getInstance();
this.logInfo("ActionValidator initialized.");
}
validate(target) {
const action = target.action;
this.logInfo(`Validating action: "${action}"`);
if (!action || typeof action !== "string") {
this.throwValidationError("action", action, "Action name must be a non-empty string.");
}
const registeredAction = this.actionRegistry.getAction(action);
if (!registeredAction) {
this.throwValidationError("action", action, `Action "${action}" is not registered in the ActionRegistry.`);
}
this.logValidationSuccess("action", action);
}
validateProperty(key, value) {
if (key === "action") {
this.validate({ action: value });
}
else {
this.throwValidationError(key, value, `Unknown property key: "${String(key)}".`);
}
}
}
//# sourceMappingURL=ActionValidator.js.map