Skip to content

Commit

Permalink
Implement MissingPropertyValidationRule
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 8, 2022
1 parent 39d75fe commit 6ce8db6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/src/providers/validation/MissingPropertyValidation.ts
Original file line number Diff line number Diff line change
@@ -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<Diagnostic[]> {
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);
}
}

0 comments on commit 6ce8db6

Please sign in to comment.