Skip to content

Commit

Permalink
Fix validation test for properties with Any type
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 21, 2024
1 parent 85e3cd6 commit 8175806
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions server/gx-workflow-ls-format2/src/schema/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ export class EnumSchemaNode implements SchemaNode {
return this._schemaEnum.name;
}

public matchesType(typeName: string): boolean {
return this.name === "Any" || this.symbols.includes(typeName);
}

//Override toString for debugging purposes
public toString(): string {
return `EnumSchemaNode: ${this.name} - ${this.symbols}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,20 @@ export class GxFormat2SchemaValidationService implements WorkflowValidator {
}
}
}

private validateEnumValue(
node: StringASTNode,
schemaRecord: EnumSchemaNode,
enumSchemaNode: EnumSchemaNode,
range: Range,
diagnostics: Diagnostic[]
): void {
if (!schemaRecord.symbols.includes(node.value)) {
if (!enumSchemaNode.matchesType(node.value)) {
diagnostics.push(
Diagnostic.create(
range,
`The value is not a valid '${schemaRecord.name}'. Allowed values are: ${schemaRecord.symbols.join(", ")}.`,
`The value is not a valid '${enumSchemaNode.name}'. Allowed values are: ${enumSchemaNode.symbols.join(
", "
)}.`,
DiagnosticSeverity.Error
)
);
Expand Down

0 comments on commit 8175806

Please sign in to comment.