Skip to content

Commit

Permalink
Merge pull request #497 from idaholab/fix/492-in-operator
Browse files Browse the repository at this point in the history
Fix/492 in operator
  • Loading branch information
browjm4 authored Nov 14, 2024
2 parents 8ba77c9 + 8803f7f commit 36b0fe5
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,25 @@ export default class TypeTransformation extends BaseDomainClass {
let results: Node[] | Edge[] = [];
// if no root array, act normally
if (!this.root_array) {

let valid = false;

// no conditions immediately equals true
if (!this.conditions || this.conditions.length === 0) valid = true;

if (this.conditions) {
for (const condition of this.conditions) {
const isValid = TypeTransformation.validTransformationCondition(condition, data.data as {[key: string]: any});
if (isValid) {
valid = true;
break;
}
}
}

// we don't error out on a non-matching condition, simply pass the transformation by
if (!valid) return new Promise((resolve) => resolve(Result.Success([])));

const results = await this.generateResults(data);

if (results.isError) {
Expand Down Expand Up @@ -790,6 +809,7 @@ export default class TypeTransformation extends BaseDomainClass {
const value = this.getNestedValue(condition.key!, payload, index);

if (!value) return false;

let rootExpressionResult = TypeTransformation.compare(condition.operator!, value, condition.value);

// handle subexpressions
Expand Down Expand Up @@ -823,8 +843,7 @@ export default class TypeTransformation extends BaseDomainClass {
}

case 'in': {
const expectedValues = expected.split(',');

const expectedValues = expected.split(',').map((item: string) => item.trim()); //split by comma and trim whitespace
return expectedValues.includes(value);
}

Expand Down

0 comments on commit 36b0fe5

Please sign in to comment.