@carecard/validate 2.2.8 → 2.2.10

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.
@@ -1,152 +1,159 @@
1
1
  // Validate the property values format.
2
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,
15
- isImageUrl,
16
- isValidDomainName,
3
+ isEmailString,
4
+ isPhoneNumber,
5
+ isUrlSafeString,
6
+ isValidUuidString,
7
+ isSimplePasswordString,
8
+ isPasswordString,
9
+ isString6To16CharacterLong,
10
+ isNameString,
11
+ isSafeSearchString,
12
+ isCharactersString,
13
+ isValidIntegerString,
14
+ isValidJsonString,
15
+ isImageUrl,
16
+ isValidDomainName,
17
17
  } = require('./validate');
18
18
 
19
19
  function validateProperties(obj = {}) {
20
- const returnObj = {};
20
+ const returnObj = {};
21
21
 
22
- for (const [key, value] of Object.entries(obj || {})) {
23
- switch (key) {
24
- case 'first_name':
25
- case 'firstName':
26
- case 'username':
27
- case 'new_status':
28
- case 'newStatus':
29
- case 'description':
30
- case 'comment':
31
- case 'status':
32
- case 'name':
33
- case 'title':
34
- case 'brand':
35
- case 'short_description':
36
- case 'shortDescription':
37
- case 'college_name':
38
- case 'collegeName':
39
- case 'campus_name':
40
- case 'campusName':
41
- if (isNameString(value)) {
42
- returnObj[key] = value;
22
+ for (const [key, value] of Object.entries(obj || {})) {
23
+ switch (key) {
24
+ case 'first_name':
25
+ case 'firstName':
26
+ case 'username':
27
+ case 'new_status':
28
+ case 'newStatus':
29
+ case 'description':
30
+ case 'comment':
31
+ case 'status':
32
+ case 'name':
33
+ case 'title':
34
+ case 'brand':
35
+ case 'short_description':
36
+ case 'shortDescription':
37
+ case 'college_name':
38
+ case 'collegeName':
39
+ case 'campus_name':
40
+ case 'campusName':
41
+ case 'role':
42
+ if (isNameString(value)) {
43
+ returnObj[key] = value;
44
+ }
45
+ break;
46
+ case 'search_string':
47
+ case 'searchString':
48
+ if (isSafeSearchString(value)) {
49
+ returnObj[key] = value;
50
+ }
51
+ break;
52
+ case 'password':
53
+ case 'new_password':
54
+ case 'newPassword':
55
+ if (isString6To16CharacterLong(value) && isSimplePasswordString(value)) {
56
+ returnObj[key] = value;
57
+ }
58
+ break;
59
+ case 'strong_password':
60
+ case 'strongPassword':
61
+ if (isString6To16CharacterLong(value) && isPasswordString(value)) {
62
+ returnObj[key] = value;
63
+ }
64
+ break;
65
+ case 'email':
66
+ if (isEmailString(value)) {
67
+ returnObj[key] = value;
68
+ }
69
+ break;
70
+ case 'phone_number':
71
+ case 'phoneNumber':
72
+ if (isPhoneNumber(value)) {
73
+ returnObj[key] = value;
74
+ }
75
+ break;
76
+ case 'token':
77
+ case 'email_confirm_token':
78
+ case 'emailConfirmToken':
79
+ case 'verification_token':
80
+ case 'verificationToken':
81
+ if (isUrlSafeString(value)) {
82
+ returnObj[key] = value;
83
+ }
84
+ break;
85
+ case 'uuid':
86
+ case 'item_id':
87
+ case 'user_id':
88
+ case 'image_id':
89
+ case 'itemId':
90
+ case 'userId':
91
+ case 'imageId':
92
+ case 'order_id':
93
+ case 'orderId':
94
+ case 'category_id':
95
+ case 'categoryId':
96
+ case 'parent_id':
97
+ case 'parentId':
98
+ case 'college_id':
99
+ case 'collegeId':
100
+ case 'campus_id':
101
+ case 'campusId':
102
+ case 'program_id':
103
+ case 'programId':
104
+ if (isValidUuidString(value)) {
105
+ returnObj[key] = value;
106
+ }
107
+ break;
108
+ case 'period':
109
+ if (isCharactersString(value)) {
110
+ returnObj[key] = value;
111
+ }
112
+ break;
113
+ case 'offset_number':
114
+ case 'offsetNumber':
115
+ case 'number_of_orders':
116
+ case 'numberOfOrders':
117
+ case 'price':
118
+ if (isValidIntegerString(value)) {
119
+ returnObj[key] = value;
120
+ }
121
+ break;
122
+ case 'about':
123
+ if (isValidJsonString(value)) {
124
+ returnObj[key] = value.trim();
125
+ }
126
+ break;
127
+ case 'weight':
128
+ case 'dimensions':
129
+ case 'permission':
130
+ if (isValidJsonString(JSON.stringify(value))) {
131
+ returnObj[key] = value;
132
+ }
133
+ break;
134
+ case 'image_url':
135
+ case 'imageUrl':
136
+ if (isImageUrl(value)) {
137
+ returnObj[key] = value;
138
+ }
139
+ break;
140
+ case 'domain_name':
141
+ case 'domainName':
142
+ case 'domain':
143
+ case 'email_domain':
144
+ case 'emailDomain':
145
+ case 'email_domain_name':
146
+ case 'emailDomainName':
147
+ if (isValidDomainName(value)) {
148
+ returnObj[key] = value;
149
+ }
150
+ break;
43
151
  }
44
- break;
45
- case 'search_string':
46
- case 'searchString':
47
- if (isSafeSearchString(value)) {
48
- returnObj[key] = value;
49
- }
50
- break;
51
- case 'password':
52
- case 'new_password':
53
- case 'newPassword':
54
- if (isString6To16CharacterLong(value) && isSimplePasswordString(value)) {
55
- returnObj[key] = value;
56
- }
57
- break;
58
- case 'strong_password':
59
- case 'strongPassword':
60
- if (isString6To16CharacterLong(value) && isPasswordString(value)) {
61
- returnObj[key] = value;
62
- }
63
- break;
64
- case 'email':
65
- if (isEmailString(value)) {
66
- returnObj[key] = value;
67
- }
68
- break;
69
- case 'phone_number':
70
- case 'phoneNumber':
71
- if (isPhoneNumber(value)) {
72
- returnObj[key] = value;
73
- }
74
- break;
75
- case 'token':
76
- case 'email_confirm_token':
77
- case 'emailConfirmToken':
78
- case 'verification_token':
79
- case 'verificationToken':
80
- if (isUrlSafeString(value)) {
81
- returnObj[key] = value;
82
- }
83
- break;
84
- case 'uuid':
85
- case 'item_id':
86
- case 'user_id':
87
- case 'image_id':
88
- case 'itemId':
89
- case 'userId':
90
- case 'imageId':
91
- case 'order_id':
92
- case 'orderId':
93
- case 'category_id':
94
- case 'categoryId':
95
- case 'parent_id':
96
- case 'parentId':
97
- if (isValidUuidString(value)) {
98
- returnObj[key] = value;
99
- }
100
- break;
101
- case 'period':
102
- if (isCharactersString(value)) {
103
- returnObj[key] = value;
104
- }
105
- break;
106
- case 'offset_number':
107
- case 'offsetNumber':
108
- case 'number_of_orders':
109
- case 'numberOfOrders':
110
- case 'price':
111
- if (isValidIntegerString(value)) {
112
- returnObj[key] = value;
113
- }
114
- break;
115
- case 'about':
116
- if (isValidJsonString(value)) {
117
- returnObj[key] = value.trim();
118
- }
119
- break;
120
- case 'weight':
121
- case 'dimensions':
122
- case 'permission':
123
- if (isValidJsonString(JSON.stringify(value))) {
124
- returnObj[key] = value;
125
- }
126
- break;
127
- case 'image_url':
128
- case 'imageUrl':
129
- if (isImageUrl(value)) {
130
- returnObj[key] = value;
131
- }
132
- break;
133
- case 'domain_name':
134
- case 'domainName':
135
- case 'domain':
136
- case 'email_domain':
137
- case 'emailDomain':
138
- case 'email_domain_name':
139
- case 'emailDomainName':
140
- if (isValidDomainName(value)) {
141
- returnObj[key] = value;
142
- }
143
- break;
144
152
  }
145
- }
146
153
 
147
- return returnObj;
154
+ return returnObj;
148
155
  }
149
156
 
150
157
  module.exports = {
151
- validateProperties,
158
+ validateProperties,
152
159
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/validate",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/CareCard-ca/pkg-validate.git"
@@ -17,6 +17,6 @@
17
17
  "author": "CareCard team",
18
18
  "license": "ISC",
19
19
  "devDependencies": {
20
- "mocha": "11.3.0"
20
+ "mocha": "11.7.5"
21
21
  }
22
22
  }