@carecard/validate 1.0.0 → 2.0.1

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.
@@ -0,0 +1,378 @@
1
+ TN:
2
+ SF:src/index.ts
3
+ FNF:0
4
+ FNH:0
5
+ DA:1,2
6
+ DA:2,2
7
+ LF:2
8
+ LH:2
9
+ BRF:0
10
+ BRH:0
11
+ end_of_record
12
+ TN:
13
+ SF:src/validate.ts
14
+ FN:1,(anonymous_0)
15
+ FN:8,(anonymous_1)
16
+ FN:12,(anonymous_2)
17
+ FN:23,(anonymous_3)
18
+ FN:28,(anonymous_4)
19
+ FN:33,(anonymous_5)
20
+ FN:38,(anonymous_6)
21
+ FN:43,(anonymous_7)
22
+ FN:48,(anonymous_8)
23
+ FN:55,(anonymous_9)
24
+ FN:61,(anonymous_10)
25
+ FN:67,(anonymous_11)
26
+ FN:73,(anonymous_12)
27
+ FN:81,(anonymous_13)
28
+ FN:89,(anonymous_14)
29
+ FN:94,isPhoneNumber
30
+ FN:99,(anonymous_16)
31
+ FN:105,(anonymous_17)
32
+ FN:110,(anonymous_18)
33
+ FN:115,(anonymous_19)
34
+ FN:125,(anonymous_20)
35
+ FN:129,(anonymous_21)
36
+ FN:139,(anonymous_22)
37
+ FN:144,(anonymous_23)
38
+ FN:152,(anonymous_24)
39
+ FNF:25
40
+ FNH:25
41
+ FNDA:3,(anonymous_0)
42
+ FNDA:5,(anonymous_1)
43
+ FNDA:7,(anonymous_2)
44
+ FNDA:5,(anonymous_3)
45
+ FNDA:5,(anonymous_4)
46
+ FNDA:4,(anonymous_5)
47
+ FNDA:19,(anonymous_6)
48
+ FNDA:15,(anonymous_7)
49
+ FNDA:4,(anonymous_8)
50
+ FNDA:4,(anonymous_9)
51
+ FNDA:15,(anonymous_10)
52
+ FNDA:15,(anonymous_11)
53
+ FNDA:1,(anonymous_12)
54
+ FNDA:1,(anonymous_13)
55
+ FNDA:4,(anonymous_14)
56
+ FNDA:2,isPhoneNumber
57
+ FNDA:2,(anonymous_16)
58
+ FNDA:2,(anonymous_17)
59
+ FNDA:3,(anonymous_18)
60
+ FNDA:3,(anonymous_19)
61
+ FNDA:3,(anonymous_20)
62
+ FNDA:3,(anonymous_21)
63
+ FNDA:2,(anonymous_22)
64
+ FNDA:2,(anonymous_23)
65
+ FNDA:3,(anonymous_24)
66
+ DA:1,2
67
+ DA:2,3
68
+ DA:4,3
69
+ DA:5,3
70
+ DA:8,2
71
+ DA:9,5
72
+ DA:12,2
73
+ DA:13,7
74
+ DA:15,5
75
+ DA:16,5
76
+ DA:17,3
77
+ DA:19,2
78
+ DA:23,2
79
+ DA:24,5
80
+ DA:25,3
81
+ DA:28,2
82
+ DA:29,5
83
+ DA:30,3
84
+ DA:33,2
85
+ DA:34,4
86
+ DA:35,2
87
+ DA:38,2
88
+ DA:39,19
89
+ DA:40,19
90
+ DA:43,2
91
+ DA:44,15
92
+ DA:45,15
93
+ DA:48,2
94
+ DA:49,4
95
+ DA:51,4
96
+ DA:52,4
97
+ DA:55,2
98
+ DA:56,4
99
+ DA:57,4
100
+ DA:58,4
101
+ DA:61,2
102
+ DA:62,15
103
+ DA:63,15
104
+ DA:64,15
105
+ DA:67,2
106
+ DA:68,15
107
+ DA:69,15
108
+ DA:70,15
109
+ DA:73,2
110
+ DA:74,1
111
+ DA:75,1
112
+ DA:77,0
113
+ DA:81,2
114
+ DA:82,1
115
+ DA:83,1
116
+ DA:85,0
117
+ DA:89,2
118
+ DA:90,4
119
+ DA:91,4
120
+ DA:94,2
121
+ DA:95,2
122
+ DA:96,2
123
+ DA:99,2
124
+ DA:100,2
125
+ DA:101,2
126
+ DA:102,2
127
+ DA:105,2
128
+ DA:106,2
129
+ DA:107,2
130
+ DA:110,2
131
+ DA:111,3
132
+ DA:112,3
133
+ DA:115,2
134
+ DA:116,3
135
+ DA:118,3
136
+ DA:119,3
137
+ DA:122,0
138
+ DA:125,2
139
+ DA:126,3
140
+ DA:129,2
141
+ DA:130,3
142
+ DA:132,3
143
+ DA:133,3
144
+ DA:136,0
145
+ DA:139,2
146
+ DA:140,2
147
+ DA:141,2
148
+ DA:144,2
149
+ DA:145,2
150
+ DA:146,2
151
+ DA:149,0
152
+ DA:152,2
153
+ DA:153,3
154
+ DA:155,3
155
+ DA:157,3
156
+ LF:90
157
+ LH:85
158
+ BRDA:2,0,0,0
159
+ BRDA:2,0,1,3
160
+ BRDA:2,1,0,3
161
+ BRDA:2,1,1,3
162
+ BRDA:2,1,2,3
163
+ BRDA:13,2,0,2
164
+ BRDA:13,2,1,5
165
+ BRDA:13,3,0,7
166
+ BRDA:13,3,1,6
167
+ BRDA:13,3,2,5
168
+ BRDA:24,4,0,2
169
+ BRDA:24,4,1,3
170
+ BRDA:24,5,0,5
171
+ BRDA:24,5,1,4
172
+ BRDA:24,5,2,3
173
+ BRDA:29,6,0,2
174
+ BRDA:29,6,1,3
175
+ BRDA:29,7,0,5
176
+ BRDA:29,7,1,4
177
+ BRDA:29,7,2,3
178
+ BRDA:34,8,0,2
179
+ BRDA:34,8,1,2
180
+ BRDA:34,9,0,4
181
+ BRDA:34,9,1,3
182
+ BRDA:34,9,2,2
183
+ BRDA:39,10,0,0
184
+ BRDA:39,10,1,19
185
+ BRDA:39,11,0,19
186
+ BRDA:39,11,1,19
187
+ BRDA:39,11,2,19
188
+ BRDA:44,12,0,0
189
+ BRDA:44,12,1,15
190
+ BRDA:44,13,0,15
191
+ BRDA:44,13,1,15
192
+ BRDA:44,13,2,15
193
+ BRDA:49,14,0,0
194
+ BRDA:49,14,1,4
195
+ BRDA:49,15,0,4
196
+ BRDA:49,15,1,4
197
+ BRDA:49,15,2,4
198
+ BRDA:56,16,0,0
199
+ BRDA:56,16,1,4
200
+ BRDA:56,17,0,4
201
+ BRDA:56,17,1,4
202
+ BRDA:62,18,0,0
203
+ BRDA:62,18,1,15
204
+ BRDA:62,19,0,15
205
+ BRDA:62,19,1,15
206
+ BRDA:62,19,2,15
207
+ BRDA:68,20,0,0
208
+ BRDA:68,20,1,15
209
+ BRDA:68,21,0,15
210
+ BRDA:68,21,1,15
211
+ BRDA:68,21,2,15
212
+ BRDA:74,22,0,1
213
+ BRDA:74,22,1,0
214
+ BRDA:82,23,0,1
215
+ BRDA:82,23,1,0
216
+ BRDA:90,24,0,0
217
+ BRDA:90,24,1,4
218
+ BRDA:90,25,0,4
219
+ BRDA:90,25,1,4
220
+ BRDA:90,25,2,4
221
+ BRDA:95,26,0,0
222
+ BRDA:95,26,1,2
223
+ BRDA:95,27,0,2
224
+ BRDA:95,27,1,2
225
+ BRDA:95,27,2,2
226
+ BRDA:100,28,0,0
227
+ BRDA:100,28,1,2
228
+ BRDA:100,29,0,2
229
+ BRDA:100,29,1,2
230
+ BRDA:106,30,0,0
231
+ BRDA:106,30,1,2
232
+ BRDA:106,31,0,2
233
+ BRDA:106,31,1,2
234
+ BRDA:106,31,2,2
235
+ BRDA:107,32,0,2
236
+ BRDA:107,32,1,2
237
+ BRDA:111,33,0,0
238
+ BRDA:111,33,1,3
239
+ BRDA:111,34,0,3
240
+ BRDA:111,34,1,3
241
+ BRDA:111,34,2,3
242
+ BRDA:112,35,0,3
243
+ BRDA:112,35,1,3
244
+ BRDA:118,36,0,3
245
+ BRDA:118,36,1,0
246
+ BRDA:126,37,0,3
247
+ BRDA:126,37,1,3
248
+ BRDA:132,38,0,3
249
+ BRDA:132,38,1,0
250
+ BRDA:140,39,0,0
251
+ BRDA:140,39,1,2
252
+ BRDA:140,40,0,2
253
+ BRDA:140,40,1,2
254
+ BRDA:140,40,2,2
255
+ BRDA:145,41,0,2
256
+ BRDA:145,41,1,0
257
+ BRDA:153,42,0,0
258
+ BRDA:153,42,1,3
259
+ BRDA:153,43,0,3
260
+ BRDA:153,43,1,3
261
+ BRDA:153,43,2,3
262
+ BRF:104
263
+ BRH:85
264
+ end_of_record
265
+ TN:
266
+ SF:src/validateProperties.ts
267
+ FN:18,validateProperties
268
+ FNF:1
269
+ FNH:1
270
+ FNDA:9,validateProperties
271
+ DA:2,2
272
+ DA:18,2
273
+ DA:19,9
274
+ DA:21,9
275
+ DA:22,9
276
+ DA:33,1
277
+ DA:34,1
278
+ DA:37,4
279
+ DA:38,4
280
+ DA:41,1
281
+ DA:44,1
282
+ DA:46,0
283
+ DA:49,0
284
+ DA:51,0
285
+ DA:52,0
286
+ DA:54,0
287
+ DA:55,0
288
+ DA:59,0
289
+ DA:60,0
290
+ DA:70,1
291
+ DA:71,1
292
+ DA:73,0
293
+ DA:74,0
294
+ DA:78,0
295
+ DA:79,0
296
+ DA:81,0
297
+ DA:82,0
298
+ DA:86,2
299
+ DA:87,2
300
+ DA:89,0
301
+ DA:90,0
302
+ DA:94,9
303
+ LF:32
304
+ LH:16
305
+ BRDA:18,0,0,0
306
+ BRDA:21,1,0,9
307
+ BRDA:21,1,1,0
308
+ BRDA:22,2,0,1
309
+ BRDA:22,2,1,1
310
+ BRDA:22,2,2,1
311
+ BRDA:22,2,3,1
312
+ BRDA:22,2,4,1
313
+ BRDA:22,2,5,1
314
+ BRDA:22,2,6,1
315
+ BRDA:22,2,7,1
316
+ BRDA:22,2,8,1
317
+ BRDA:22,2,9,1
318
+ BRDA:22,2,10,2
319
+ BRDA:22,2,11,4
320
+ BRDA:22,2,12,1
321
+ BRDA:22,2,13,1
322
+ BRDA:22,2,14,0
323
+ BRDA:22,2,15,0
324
+ BRDA:22,2,16,0
325
+ BRDA:22,2,17,0
326
+ BRDA:22,2,18,0
327
+ BRDA:22,2,19,0
328
+ BRDA:22,2,20,0
329
+ BRDA:22,2,21,1
330
+ BRDA:22,2,22,1
331
+ BRDA:22,2,23,1
332
+ BRDA:22,2,24,1
333
+ BRDA:22,2,25,1
334
+ BRDA:22,2,26,1
335
+ BRDA:22,2,27,1
336
+ BRDA:22,2,28,1
337
+ BRDA:22,2,29,0
338
+ BRDA:22,2,30,0
339
+ BRDA:22,2,31,0
340
+ BRDA:22,2,32,0
341
+ BRDA:22,2,33,0
342
+ BRDA:22,2,34,0
343
+ BRDA:22,2,35,0
344
+ BRDA:22,2,36,2
345
+ BRDA:22,2,37,0
346
+ BRDA:33,3,0,1
347
+ BRDA:33,3,1,0
348
+ BRDA:37,4,0,2
349
+ BRDA:37,4,1,2
350
+ BRDA:41,5,0,1
351
+ BRDA:41,5,1,0
352
+ BRDA:41,6,0,1
353
+ BRDA:41,6,1,1
354
+ BRDA:46,7,0,0
355
+ BRDA:46,7,1,0
356
+ BRDA:46,8,0,0
357
+ BRDA:46,8,1,0
358
+ BRDA:51,9,0,0
359
+ BRDA:51,9,1,0
360
+ BRDA:54,10,0,0
361
+ BRDA:54,10,1,0
362
+ BRDA:59,11,0,0
363
+ BRDA:59,11,1,0
364
+ BRDA:70,12,0,1
365
+ BRDA:70,12,1,0
366
+ BRDA:73,13,0,0
367
+ BRDA:73,13,1,0
368
+ BRDA:78,14,0,0
369
+ BRDA:78,14,1,0
370
+ BRDA:81,15,0,0
371
+ BRDA:81,15,1,0
372
+ BRDA:86,16,0,2
373
+ BRDA:86,16,1,0
374
+ BRDA:89,17,0,0
375
+ BRDA:89,17,1,0
376
+ BRF:71
377
+ BRH:32
378
+ end_of_record
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ validate: require( './lib/validate' ),
3
+ validateProperties: require( './lib/validateProperties' )
4
+ }
@@ -0,0 +1,190 @@
1
+ const isImageUrl = imageUrl => {
2
+ if ( imageUrl === undefined || typeof imageUrl !== "string" || imageUrl.length === 0 ) return false;
3
+
4
+ const imageUrlRegex = /^[a-zA-Z0-9-_./]+$/;
5
+ return imageUrlRegex.test( imageUrl );
6
+ };
7
+
8
+ const isInteger = number => {
9
+ return Number.isInteger( number );
10
+ };
11
+
12
+ const isValidJsonString = str => {
13
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
14
+
15
+ try {
16
+ const json = JSON.parse( str );
17
+ return ( typeof json === 'object' );
18
+ } catch ( error ) {
19
+ return false;
20
+ }
21
+ };
22
+
23
+ const isValidIntegerString = str => {
24
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
25
+ return ( /^\d+$/g.test( str ) );
26
+ }
27
+
28
+ const isValidUuidString = str => {
29
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
30
+ return ( /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test( str ) );
31
+ }
32
+
33
+ const isCharactersString = str => {
34
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
35
+ return ( /^[\da-zA-Z _-]+$/.test( str ) );
36
+ }
37
+
38
+ const isNameString = str => {
39
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
40
+ return ( /^[A-Za-z][0-9a-zA-Z-_.,'() ]+$/.test( str.trim() ) );
41
+ }
42
+
43
+ const isSafeSearchString = str => {
44
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
45
+ return /^[A-Za-z][0-9a-zA-Z\-_.,'()@ ]{1,100}$/.test( str.trim() );
46
+ }
47
+
48
+ const isEmailString = email => {
49
+ if ( email === undefined || typeof email !== "string" || email.length === 0 ) return false;
50
+ const regExpEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
51
+ return regExpEmail.test( String( email ).toLowerCase() );
52
+ }
53
+
54
+ const isJwtString = ( jwt ) => {
55
+ if ( jwt === '' || jwt.trim() === '' ) return false;
56
+ const jwtRegex = /^eyJ[a-zA-Z0-9-_.]+$/;
57
+ return jwtRegex.test( jwt );
58
+ }
59
+
60
+ const isPasswordString = password => {
61
+ if ( password === undefined || typeof password !== "string" || password.length === 0 ) return false;
62
+ const regExPassword = /^(?=.*[a-zA-Z0-9])(?=.*[!@#$%^&*_-])[a-zA-Z0-9!@#$%^&*_-]{6,32}$/;
63
+ return regExPassword.test( String( password ) );
64
+ }
65
+
66
+ const isSimplePasswordString = password => {
67
+ if ( password === undefined || typeof password !== "string" || password.length === 0 ) return false;
68
+ const regExPassword = /^[a-zA-Z0-9!@#$%^&*_-]{6,32}$/;
69
+ return regExPassword.test( String( password ) );
70
+ }
71
+
72
+ const isPasswordStringFailureMessage = ( password ) => {
73
+ if ( !isPasswordString( password ) ) {
74
+ return "Total 6 to 32 characters, numbers and one of !@#$%^&*_-";
75
+ } else {
76
+ return null;
77
+ }
78
+ }
79
+
80
+ const isSimplePasswordStringFailureMessage = ( password ) => {
81
+ if ( !isPasswordString( password ) ) {
82
+ return "Total 6 to 32 characters, numbers or !@#$%^&*_-";
83
+ } else {
84
+ return null;
85
+ }
86
+ }
87
+
88
+ const isUsernameString = str => {
89
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
90
+ return ( /^[0-9a-zA-Z]+$/.test( str ) );
91
+ }
92
+
93
+ function isPhoneNumber( str ) {
94
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
95
+ return ( /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/.test( str ) );
96
+ }
97
+
98
+ const isUrlSafeString = ( inputString ) => {
99
+ if ( inputString === '' || inputString.trim() === '' ) return false;
100
+ const jwtRegex = /^[a-zA-Z0-9-_.]+$/;
101
+ return jwtRegex.test( inputString );
102
+ }
103
+
104
+ const isString6To24CharacterLong = ( password ) => {
105
+ if ( password === undefined || typeof password !== "string" || password.length === 0 ) return false;
106
+ return 6 <= password.length && password.length <= 24;
107
+ };
108
+
109
+ const isString6To16CharacterLong = ( password ) => {
110
+ if ( password === undefined || typeof password !== "string" || password.length === 0 ) return false;
111
+ return 6 <= password.length && password.length <= 16;
112
+ };
113
+
114
+ const isProvinceString = ( inputString ) => {
115
+ const provinces = [ 'on', 'qc' ];
116
+
117
+ if ( isNameString( inputString ) ) {
118
+ return provinces.includes( inputString.toLowerCase() );
119
+ }
120
+
121
+ return false
122
+ };
123
+
124
+ const isBoolValue = ( inputValue ) => {
125
+ return !( inputValue === undefined || typeof inputValue !== "boolean" );
126
+ };
127
+
128
+ const isPostalCodeString = ( inputString ) => {
129
+
130
+ const postalCodeRegex = /^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$/i;
131
+
132
+ if ( isNameString( inputString ) ) {
133
+ return postalCodeRegex.test( inputString );
134
+ }
135
+
136
+ return false;
137
+ };
138
+
139
+ const isSafeString = ( str ) => {
140
+
141
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
142
+ return ( /^[\da-zA-Z-_.,#*'()\[\]: ]+$/.test( str ) );
143
+
144
+ }
145
+
146
+ const isInStringArray = ( StringArray, inputString ) => {
147
+
148
+ if ( isNameString( inputString ) ) {
149
+ return StringArray.includes( inputString.toLowerCase() );
150
+ }
151
+
152
+ return false
153
+ };
154
+
155
+ const isCountryCodeString = ( str ) => {
156
+
157
+ if ( str === undefined || typeof str !== "string" || str.length === 0 ) return false;
158
+
159
+ const postalCodeRegex = /^\+[1-9][0-9]{0,2}$/i;
160
+
161
+ return postalCodeRegex.test( str );
162
+ };
163
+
164
+ module.exports = {
165
+ isImageUrl,
166
+ isInteger,
167
+ isValidJsonString,
168
+ isValidIntegerString,
169
+ isValidUuidString,
170
+ isCharactersString,
171
+ isNameString,
172
+ isSafeSearchString,
173
+ isEmailString,
174
+ isJwtString,
175
+ isPasswordString,
176
+ isSimplePasswordString,
177
+ isPasswordStringFailureMessage,
178
+ isSimplePasswordStringFailureMessage,
179
+ isUsernameString,
180
+ isPhoneNumber,
181
+ isUrlSafeString,
182
+ isString6To24CharacterLong,
183
+ isString6To16CharacterLong,
184
+ isProvinceString,
185
+ isBoolValue,
186
+ isPostalCodeString,
187
+ isSafeString,
188
+ isInStringArray,
189
+ isCountryCodeString
190
+ };
@@ -0,0 +1,106 @@
1
+ // Validate the property values format.
2
+ const {
3
+ isEmailString,
4
+ isPhoneNumber,
5
+ isUrlSafeString,
6
+ isValidUuidString,
7
+ isSimplePasswordString,
8
+ isPasswordString,
9
+ isString6To16CharacterLong,
10
+ isNameString,
11
+ isSafeSearchString,
12
+ isCharactersString,
13
+ isValidIntegerString,
14
+ isValidJsonString, isImageUrl
15
+ } = require( "./validate" );
16
+
17
+ function validateProperties( obj ) {
18
+ let returnObj = {};
19
+
20
+ for ( let [ key, value ] of Object.entries( obj || {} ) ) {
21
+
22
+ switch ( key ) {
23
+ case "first_name" :
24
+ case "username" :
25
+ case "newStatus":
26
+ case "description":
27
+ case "comment":
28
+ case "status":
29
+ case "name":
30
+ case "title" :
31
+ case "brand":
32
+ case "short_description" :
33
+ isNameString( value ) ?
34
+ returnObj[ key ] = value : null;
35
+ break;
36
+ case "search_string":
37
+ case "searchString":
38
+ isSafeSearchString( value ) ?
39
+ returnObj[ key ] = value : null;
40
+ break;
41
+ case "password" :
42
+ case "new_password" :
43
+ isString6To16CharacterLong( value ) && isSimplePasswordString( value ) ?
44
+ returnObj[ key ] = value : null;
45
+ break;
46
+ case "strong_password" :
47
+ isString6To16CharacterLong( value ) && isPasswordString( value ) ?
48
+ returnObj[ key ] = value : null;
49
+ break;
50
+ case "email" :
51
+ isEmailString( value ) ?
52
+ returnObj[ key ] = value : null;
53
+ break;
54
+ case "phone_number":
55
+ isPhoneNumber( value ) ?
56
+ returnObj[ key ] = value : null;
57
+ break;
58
+ case "token":
59
+ case "email_confirm_token":
60
+ case "verification_token":
61
+ isUrlSafeString( value ) ?
62
+ returnObj[ key ] = value : null;
63
+ break;
64
+ case "uuid":
65
+ case "item_id":
66
+ case "user_id":
67
+ case "userId":
68
+ case "image_id":
69
+ case "itemId":
70
+ case "userId":
71
+ case "orderId":
72
+ case "category_id":
73
+ case "parent_id":
74
+ isValidUuidString( value ) ?
75
+ returnObj[ key ] = value : null;
76
+ break;
77
+ case "period":
78
+ isCharactersString( value ) ?
79
+ returnObj[ key ] = value : null;
80
+ break;
81
+ case "offset_number":
82
+ case "number_of_orders":
83
+ case "price":
84
+ isValidIntegerString( value ) ?
85
+ returnObj[ key ] = value : null;
86
+ break;
87
+ case "about":
88
+ isValidJsonString( value ) ? returnObj[ key ] = value.trim() : null;
89
+ break;
90
+ case "weight":
91
+ case "dimensions":
92
+ case "permission":
93
+ isValidJsonString( JSON.stringify( value ) ) ? returnObj[ key ] = value : null;
94
+ break;
95
+ case "image_url":
96
+ isImageUrl( value ) ? returnObj[ key ] = value : null;
97
+ break;
98
+ }
99
+ }
100
+
101
+ return returnObj;
102
+ }
103
+
104
+ module.exports = {
105
+ validateProperties
106
+ };