mirror of
https://github.com/Nighthawk42/roll20-character-sheets.git
synced 2026-09-11 17:42:29 +00:00
* Add helper function for checking objects for required properties
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user