@hello.nrfcloud.com/proto-map 10.0.3 → 10.0.4
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/dist/lwm2m/validate.spec.js +18 -0
- package/dist/lwm2m/validation.js +1 -0
- package/lwm2m/validate.spec.ts +19 -0
- package/lwm2m/validation.ts +1 -0
- package/package.json +1 -1
|
@@ -24,4 +24,22 @@ void describe('validate()', function() {
|
|
|
24
24
|
var maybeValid = v({});
|
|
25
25
|
assert.equal('error' in maybeValid, true);
|
|
26
26
|
});
|
|
27
|
+
void it('should validate an object with undefined optional resources', function() {
|
|
28
|
+
var object = {
|
|
29
|
+
ObjectID: 14203,
|
|
30
|
+
ObjectVersion: '1.0',
|
|
31
|
+
Resources: {
|
|
32
|
+
'0': 'LTE-M GPS',
|
|
33
|
+
'1': 20,
|
|
34
|
+
'3': 33187,
|
|
35
|
+
'4': 52661514,
|
|
36
|
+
'5': 24201,
|
|
37
|
+
'6': '10.234.105.140',
|
|
38
|
+
11: undefined,
|
|
39
|
+
'99': 1716988087000
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var maybeValid = v(object);
|
|
43
|
+
assert.deepEqual('object' in maybeValid && maybeValid.object, object);
|
|
44
|
+
});
|
|
27
45
|
});
|
package/dist/lwm2m/validation.js
CHANGED
|
@@ -80,6 +80,7 @@ export var isLwM2MObject = function(object) {
|
|
|
80
80
|
// All values must be number, string, boolean
|
|
81
81
|
for(var _iterator = Object.values(object.Resources)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
82
82
|
var v = _step.value;
|
|
83
|
+
if (v === undefined) continue;
|
|
83
84
|
if (typeof v === 'string') continue;
|
|
84
85
|
if (typeof v === 'boolean') continue;
|
|
85
86
|
if (typeof v === 'number') continue;
|
package/lwm2m/validate.spec.ts
CHANGED
|
@@ -26,4 +26,23 @@ void describe('validate()', () => {
|
|
|
26
26
|
const maybeValid = v({})
|
|
27
27
|
assert.equal('error' in maybeValid, true)
|
|
28
28
|
})
|
|
29
|
+
|
|
30
|
+
void it('should validate an object with undefined optional resources', () => {
|
|
31
|
+
const object = {
|
|
32
|
+
ObjectID: 14203,
|
|
33
|
+
ObjectVersion: '1.0',
|
|
34
|
+
Resources: {
|
|
35
|
+
'0': 'LTE-M GPS',
|
|
36
|
+
'1': 20,
|
|
37
|
+
'3': 33187,
|
|
38
|
+
'4': 52661514,
|
|
39
|
+
'5': 24201,
|
|
40
|
+
'6': '10.234.105.140',
|
|
41
|
+
11: undefined,
|
|
42
|
+
'99': 1716988087000,
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
const maybeValid = v(object)
|
|
46
|
+
assert.deepEqual('object' in maybeValid && maybeValid.object, object)
|
|
47
|
+
})
|
|
29
48
|
})
|
package/lwm2m/validation.ts
CHANGED
|
@@ -50,6 +50,7 @@ export const isLwM2MObject = (
|
|
|
50
50
|
return error(`All resource IDs must be a number`)
|
|
51
51
|
// All values must be number, string, boolean
|
|
52
52
|
for (const v of Object.values(object.Resources)) {
|
|
53
|
+
if (v === undefined) continue
|
|
53
54
|
if (typeof v === 'string') continue
|
|
54
55
|
if (typeof v === 'boolean') continue
|
|
55
56
|
if (typeof v === 'number') continue
|
package/package.json
CHANGED