Skip to content

Commit b33b400

Browse files
committed
Bugfix V validation
Required fields
1 parent 080af71 commit b33b400

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

_static/RDL_MDE.html

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5270,21 +5270,37 @@ <h5 class="modal-title" id="githubConfigModalLabel">GitHub Configuration</h5>
52705270
const requiredVulnerabilityAttributes = [
52715271
{ field: 'hazard_primary', name: 'primary hazard type' },
52725272
{ field: 'hazard_analysis_type', name: 'hazard analysis type' },
5273-
{ field: 'intensity', name: 'hazard intensity measurement' },
5273+
{ field: 'intensity_measure', name: 'hazard intensity measurement' },
52745274
{ field: 'category', name: 'exposure category' },
52755275
{ field: 'impact_type', name: 'impact type' },
52765276
{ field: 'impact_modelling', name: 'impact modelling' },
52775277
{ field: 'impact_metric', name: 'impact metric' },
52785278
{ field: 'quantity_kind', name: 'quantity kind' }
52795279
];
52805280

5281-
// Check each required attribute
5282-
for (const attr of requiredVulnerabilityAttributes) {
5283-
if (!vulnerability[attr.field] || vulnerability[attr.field].toString().trim() === '') {
5284-
vulnerabilityValid = false;
5285-
vulnerabilityError = `Vulnerability is missing required ${attr.name}`;
5286-
break;
5281+
// Check each function type (vulnerability, fragility, damage_to_loss, engineering_demand)
5282+
for (const funcType of Object.keys(vulnerability.functions)) {
5283+
const funcArray = vulnerability.functions[funcType];
5284+
if (Array.isArray(funcArray) && funcArray.length > 0) {
5285+
// Validate each function in the array
5286+
for (let i = 0; i < funcArray.length; i++) {
5287+
const func = funcArray[i];
5288+
const funcNum = i + 1;
5289+
5290+
// Check each required attribute
5291+
for (const attr of requiredVulnerabilityAttributes) {
5292+
if (!func[attr.field] || func[attr.field].toString().trim() === '') {
5293+
vulnerabilityValid = false;
5294+
vulnerabilityError = `${funcType} function ${funcNum} is missing required ${attr.name}`;
5295+
break;
5296+
}
5297+
}
5298+
5299+
if (!vulnerabilityValid) break;
5300+
}
52875301
}
5302+
5303+
if (!vulnerabilityValid) break;
52885304
}
52895305
}
52905306
}

_static/rdls_schema_v0.3.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@
600600
"title": "Vulnerability function",
601601
"type": "object",
602602
"description": "The vulnerability function used to calculate the impact of the hazard.",
603-
"required": ["approach", "relationship"],
603+
"required": ["approach", "relationship", "hazard_primary", "hazard_analysis_type", "intensity_measure", "category", "impact_type", "impact_modelling", "impact_metric", "quantity_kind"],
604604
"properties": {
605605
"approach": {
606606
"title": "Vulnerability function approach",
@@ -710,7 +710,7 @@
710710
"title": "Fragility function",
711711
"type": "object",
712712
"description": "The fragility function used to calculate the impact of the hazard.",
713-
"required": ["approach", "relationship"],
713+
"required": ["approach", "relationship", "hazard_primary", "hazard_analysis_type", "intensity_measure", "category", "impact_type", "impact_modelling", "impact_metric", "quantity_kind"],
714714
"properties": {
715715
"approach": {
716716
"title": "Fragility function approach",
@@ -846,7 +846,7 @@
846846
"title": "Damage-to-loss function",
847847
"type": "object",
848848
"description": "The damage-to-loss function (or damage-to-loss model) used to calculate the impact of the hazard in conjunction with a fragility function.",
849-
"required": ["approach", "relationship"],
849+
"required": ["approach", "relationship", "hazard_primary", "hazard_analysis_type", "intensity_measure", "category", "impact_type", "impact_modelling", "impact_metric", "quantity_kind"],
850850
"properties": {
851851
"approach": {
852852
"title": "Damage-to-loss function approach",
@@ -982,7 +982,7 @@
982982
"title": "Engineering demand function",
983983
"type": "object",
984984
"description": "The engineering demand function used to calculate the impact of the hazard.",
985-
"required": ["approach", "relationship"],
985+
"required": ["approach", "relationship", "hazard_primary", "hazard_analysis_type", "intensity_measure", "category", "impact_type", "impact_modelling", "impact_metric", "quantity_kind"],
986986
"properties": {
987987
"parameter": {
988988
"title": "Engineering demand parameter",

0 commit comments

Comments
 (0)