Skip to content

Commit f2f905c

Browse files
update properties validation message
1 parent 7c5a814 commit f2f905c

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

client/__tests__/track.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('track', () => {
145145

146146
test('should be 400 if properties is invalid', async () => {
147147
const expected = [
148-
'properties must be a plain object.'
148+
'properties must be a plain object with only boolean, string, number or null values..'
149149
];
150150
const response = await request(app)
151151
.get('/client/track?key=my-key&event-type=my-event&traffic-type=my-traffic&value=1&properties=lalala')
@@ -158,7 +158,7 @@ describe('track', () => {
158158
'key too long, key must be 250 characters or less.',
159159
'you passed "@!test", event-type must adhere to the regular expression /^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/g. This means an event_type must be alphanumeric, cannot be more than 80 characters long, and can only include a dash, underscore, period, or colon as separators of alphanumeric characters.',
160160
'you passed an empty traffic-type, traffic-type must be a non-empty string.',
161-
'properties must be a plain object.',
161+
'properties must be a plain object with only boolean, string, number or null values..',
162162
'value must be null or number.'
163163
];
164164
const key = getLongKey();

utils/inputValidation/__tests__/properties.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { validateProperties, validateEvaluationOptions } = require('../properties
22

33
describe('validateProperties', () => {
44
test('should return error on invalid properties', done => {
5-
const expected = 'properties must be a plain object.';
5+
const expected = 'properties must be a plain object with only boolean, string, number or null values..';
66
const result = validateProperties('test');
77
expect(result).toHaveProperty('valid', false);
88
expect(result).toHaveProperty('error', expected);
@@ -11,7 +11,7 @@ describe('validateProperties', () => {
1111
});
1212

1313
test('should return error on invalid properties 2', done => {
14-
const expected = 'properties must be a plain object.';
14+
const expected = 'properties must be a plain object with only boolean, string, number or null values..';
1515
const result = validateProperties('[]');
1616
expect(result).toHaveProperty('valid', false);
1717
expect(result).toHaveProperty('error', expected);
@@ -20,7 +20,7 @@ describe('validateProperties', () => {
2020
});
2121

2222
test('should return error on invalid properties 3', done => {
23-
const expected = 'properties must be a plain object.';
23+
const expected = 'properties must be a plain object with only boolean, string, number or null values..';
2424
const result = validateProperties('true');
2525
expect(result).toHaveProperty('valid', false);
2626
expect(result).toHaveProperty('error', expected);
@@ -108,7 +108,7 @@ describe('validateEvaluationOptions', () => {
108108
});
109109

110110
test('should return error if options.properties is not valid', done => {
111-
const expected = 'properties must be a plain object.';
111+
const expected = 'properties must be a plain object with only boolean, string, number or null values..';
112112
const result = validateEvaluationOptions('{"properties": "not-an-object"}');
113113
expect(result).toHaveProperty('valid', false);
114114
expect(result).toHaveProperty('error', expected);

utils/inputValidation/properties.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ function validateProperties(maybeProperties) {
1010
try {
1111
properties = isString(maybeProperties) ? JSON.parse(maybeProperties) : maybeProperties;
1212
if (!isObject(properties)) {
13-
return errorWrapper('properties must be a plain object.');
13+
return errorWrapper('properties must be a plain object with only boolean, string, number or null values..');
1414
}
1515
return okWrapper(properties);
1616
} catch (e) {
17-
return errorWrapper('properties must be a plain object.');
17+
return errorWrapper('properties must be a plain object with only boolean, string, number or null values..');
1818
}
1919
}
2020

0 commit comments

Comments
 (0)