@awesomeness-js/utils 1.2.10 → 1.2.12
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.
- package/package.json +1 -1
- package/src/clean/buffer.js +1 -0
- package/src/utils/clean.js +28 -0
- package/types/clean/buffer.d.ts +1 -0
package/package.json
CHANGED
package/src/clean/buffer.js
CHANGED
package/src/utils/clean.js
CHANGED
|
@@ -165,6 +165,18 @@ function cleanArray(arr, schema = {}, {
|
|
|
165
165
|
|
|
166
166
|
} else {
|
|
167
167
|
|
|
168
|
+
|
|
169
|
+
if(schema.requiredIfPresent === true){
|
|
170
|
+
|
|
171
|
+
throw {
|
|
172
|
+
message: 'requiredIfPresent item is null',
|
|
173
|
+
item,
|
|
174
|
+
key
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
|
|
168
180
|
return; // skip this item if it's not required and is null
|
|
169
181
|
|
|
170
182
|
}
|
|
@@ -410,6 +422,22 @@ function cleanObject(obj, schema, {
|
|
|
410
422
|
}
|
|
411
423
|
|
|
412
424
|
|
|
425
|
+
if(
|
|
426
|
+
schema.properties[key].required === false
|
|
427
|
+
&& schema.properties[key].requiredIfPresent === true
|
|
428
|
+
&& cleanedValue === null
|
|
429
|
+
){
|
|
430
|
+
|
|
431
|
+
throw {
|
|
432
|
+
message: 'value invalid',
|
|
433
|
+
value,
|
|
434
|
+
key,
|
|
435
|
+
requirements: schema.properties[key],
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
|
|
413
441
|
cleanObj[key] = cleanedValue;
|
|
414
442
|
|
|
415
443
|
});
|