@openframe-org/criteria-set-protocol 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/v1/utils.js +10 -7
  2. package/package.json +1 -1
package/dist/v1/utils.js CHANGED
@@ -101,40 +101,43 @@ exports.getCertificationsByValue = getCertificationsByValue;
101
101
  * In all cases, the data should contain 'text' and 'readOnly' properties
102
102
  */
103
103
  const validateData = (dataOrTreeElement) => {
104
+ if (("type" in dataOrTreeElement) && dataOrTreeElement.type === "task-item" && !("readOnly" in dataOrTreeElement)) {
105
+ throw new Error("Data is missing 'readOnly' property");
106
+ }
104
107
  const data = "data" in dataOrTreeElement ? dataOrTreeElement.data : dataOrTreeElement;
105
108
  if (!data) {
106
109
  throw new Error("Invalid data object");
107
110
  }
108
- ["readOnly", "value", "text"].forEach((property) => {
111
+ ["value", "text"].forEach((property) => {
109
112
  if (!(property in data)) {
110
- throw new Error(`Missing '${property}' property`);
113
+ throw new Error(`Data is missing '${property}' property`);
111
114
  }
112
115
  });
113
116
  switch (data.type) {
114
117
  case "number":
115
118
  case undefined: {
116
119
  if (typeof data.value !== "number") {
117
- throw new Error("Invalid numeric data");
120
+ throw new Error(`Data value is not numeric: ${data.value}`);
118
121
  }
119
122
  if (!("total" in data) || typeof data.total !== "number") {
120
- throw new Error("Invalid numeric total");
123
+ throw new Error(`Data total is missing or not numeric: ${data.total}`);
121
124
  }
122
125
  break;
123
126
  }
124
127
  case "percentage": {
125
128
  if (typeof data.value !== "number") {
126
- throw new Error("Invalid percentage data");
129
+ throw new Error(`Data value is not numeric: ${data.value}`);
127
130
  }
128
131
  break;
129
132
  }
130
133
  case "boolean": {
131
134
  if (typeof data.value !== "boolean") {
132
- throw new Error("Invalid boolean data");
135
+ throw new Error(`Data value is not a boolean: ${data.value}`);
133
136
  }
134
137
  break;
135
138
  }
136
139
  default:
137
- throw new Error(`Invalid data type: ${data.type}`);
140
+ throw new Error(`Data has an invalid 'type' property: ${data.type}`);
138
141
  }
139
142
  };
140
143
  exports.validateData = validateData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openframe-org/criteria-set-protocol",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "A protocol and tools for defining and working with criteria sets",
5
5
  "private": false,
6
6
  "author": "Andrés Angulo <aa@openframe.org>",