diff --git a/server/src/providers/validation/MissingPropertyValidation.ts b/server/src/providers/validation/MissingPropertyValidation.ts new file mode 100644 index 0000000..9302385 --- /dev/null +++ b/server/src/providers/validation/MissingPropertyValidation.ts @@ -0,0 +1,19 @@ +import { Diagnostic, DiagnosticSeverity } from "vscode-languageserver-types"; +import { ValidationContributor, WorkflowDocument } from "../../languageTypes"; + +export class MissingPropertyValidationRule implements ValidationContributor { + constructor(readonly nodePath: string, readonly severity?: DiagnosticSeverity | undefined) {} + + validate(workflowDocument: WorkflowDocument): Promise { + const result: Diagnostic[] = []; + const targetNode = workflowDocument.getNodeFromPath(this.nodePath); + if (!targetNode) { + result.push({ + message: `Property '${this.nodePath}' is missing`, + range: workflowDocument.getDefaultRange(), + severity: this.severity, + }); + } + return Promise.resolve(result); + } +}