Skip to content

Commit

Permalink
Merge pull request #82 from center-for-threat-informed-defense/AF-126…
Browse files Browse the repository at this point in the history
…_location_validation

AF-126 Location Validation
  • Loading branch information
mikecarenzo committed Jul 20, 2023
2 parents 1230825 + a895803 commit 42bca91
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/attack_flow_builder/src/assets/builder.config.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ class AttackFlowValidator extends DiagramValidator {
this.addError(id, "Invalid email address.")
}
break;
case "location": // Additional validation for location object
const region = node.props.value.get("region");
const country = node.props.value.get("country");
const latitude = node.props.value.get("latitude");
const longitude = node.props.value.get("longitude");

// Verify one of the required properties is set
if(!region?.isDefined() && !country?.isDefined() && !(latitude?.isDefined() || longitude?.isDefined())) {
this.addError(id, "Location requires one of the following properties: Region, Country, Latitude+Longitude.");
}

// Latitude + Longitude check
if(latitude?.isDefined() !== longitude?.isDefined()) {
this.addError(id, "Latitude and Longitude must be supplied together.");
}
break;
}
}

Expand Down

0 comments on commit 42bca91

Please sign in to comment.