* Add helper function for checking objects for required properties

This commit is contained in:
Kreuvf
2021-03-22 19:01:50 +01:00
parent 017269112d
commit 3f8307d9b5
@@ -16813,6 +16813,25 @@ function DSAsane (value, type) {
return !errors;
}
/*
Property Checker
Checks whether properties (given in an array of strings) are available in an object.
Does not check whether the array contains strings only.
Returns an object with the error count (missing properties) and a string array of missing properties.
*/
function checkRequiredProperties(properties, values) {
var errors = 0;
var missing = [];
for (req of properties) {
if (!values.hasOwnProperty(req)) {
errors += 1;
missing.push(req);
}
}
return { "errors": errors, "missing": missing.toString() };
}
// Berechne BE-Basis aus dem gesamten Rüstungs BE und der BE durch Last
on("change:Ges_BE change:BE_Last", function(eventInfo) {
getAttrs(["Ges_BE", "BE_Last"], function(values) {