@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.
@@ -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
  });
@@ -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;
@@ -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
  })
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/proto-map",
3
- "version": "10.0.3",
3
+ "version": "10.0.4",
4
4
  "description": "Documents the communication protocol between devices, the hello.nrfcloud.com/map backend and web application",
5
5
  "type": "module",
6
6
  "exports": {