Skip to content

Commit 1ed41a3

Browse files
committed
fix(validation): Be able to take in and validate null object event/user properties
1 parent 77a01ee commit 1ed41a3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var truncate = function truncate(value) {
6969
}
7070
} else if (type(value) === 'object') {
7171
for (var key in value) {
72-
if (value.hasOwnProperty(key)) {
72+
if (key in value) {
7373
value[key] = truncate(value[key]);
7474
}
7575
}
@@ -110,7 +110,7 @@ var validateProperties = function validateProperties(properties) {
110110

111111
var copy = {}; // create a copy with all of the valid properties
112112
for (var property in properties) {
113-
if (!properties.hasOwnProperty(property)) {
113+
if (!(property in properties)) {
114114
continue;
115115
}
116116

test/utils.js

+14
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,19 @@ describe('utils', function() {
239239
}
240240
assert.deepEqual(utils.validateProperties(properties), {});
241241
});
242+
243+
it('should validate properties on null objects', function() {
244+
var properties = Object.create(null);
245+
properties['test'] = 'yes';
246+
properties['key'] = 'value';
247+
properties['15'] = '16';
248+
249+
var expected = {
250+
'test': 'yes',
251+
'key': 'value',
252+
'15': '16'
253+
};
254+
assert.deepEqual(utils.validateProperties(properties), expected);
255+
});
242256
});
243257
});

0 commit comments

Comments
 (0)