@carecard/validate-ts 2.1.1 → 2.2.7
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.
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/validate.cjs +40 -39
- package/dist/cjs/validate.d.ts +26 -26
- package/dist/cjs/validateProperties.cjs +63 -21
- package/dist/cjs/validateProperties.d.ts +2 -2
- package/dist/esm/validate.d.ts +26 -26
- package/dist/esm/validate.js +40 -39
- package/dist/esm/validateProperties.d.ts +2 -2
- package/dist/esm/validateProperties.js +62 -20
- package/package.json +16 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./validate"), exports);
|
|
18
|
-
__exportStar(require("./validateProperties"), exports);
|
|
17
|
+
__exportStar(require("./validate.cjs"), exports);
|
|
18
|
+
__exportStar(require("./validateProperties.cjs"), exports);
|
package/dist/cjs/validate.cjs
CHANGED
|
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isValidDomainName = exports.isCountryCodeString = exports.isInStringArray = exports.isSafeString = exports.isPostalCodeString = exports.isBoolValue = exports.isProvinceString = exports.isString6To16CharacterLong = exports.isString6To24CharacterLong = exports.isUrlSafeString = exports.isUsernameString = exports.isSimplePasswordStringFailureMessage = exports.isPasswordStringFailureMessage = exports.isSimplePasswordString = exports.isPasswordString = exports.isJwtString = exports.isEmailString = exports.isSafeSearchString = exports.isNameString = exports.isCharactersString = exports.isValidUuidString = exports.isValidIntegerString = exports.isValidJsonString = exports.isInteger = exports.isImageUrl = void 0;
|
|
4
4
|
exports.isPhoneNumber = isPhoneNumber;
|
|
5
5
|
const isImageUrl = (imageUrl) => {
|
|
6
|
-
if (imageUrl === undefined ||
|
|
6
|
+
if (imageUrl === undefined ||
|
|
7
|
+
typeof imageUrl !== 'string' ||
|
|
8
|
+
imageUrl.length === 0 ||
|
|
9
|
+
imageUrl.length > 2048)
|
|
7
10
|
return false;
|
|
8
11
|
const imageUrlRegex = /^[a-zA-Z0-9-_./]+$/;
|
|
9
12
|
return imageUrlRegex.test(imageUrl);
|
|
@@ -14,21 +17,21 @@ const isInteger = (number) => {
|
|
|
14
17
|
};
|
|
15
18
|
exports.isInteger = isInteger;
|
|
16
19
|
const isValidJsonString = (str) => {
|
|
17
|
-
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
20
|
+
if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 10000)
|
|
18
21
|
return false;
|
|
19
22
|
try {
|
|
20
23
|
const json = JSON.parse(str);
|
|
21
|
-
return typeof json === 'object';
|
|
24
|
+
return typeof json === 'object' && json !== null;
|
|
22
25
|
}
|
|
23
|
-
catch
|
|
26
|
+
catch {
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
29
|
};
|
|
27
30
|
exports.isValidJsonString = isValidJsonString;
|
|
28
31
|
const isValidIntegerString = (str) => {
|
|
29
|
-
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
32
|
+
if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 20)
|
|
30
33
|
return false;
|
|
31
|
-
return /^\d
|
|
34
|
+
return /^\d+$/.test(str);
|
|
32
35
|
};
|
|
33
36
|
exports.isValidIntegerString = isValidIntegerString;
|
|
34
37
|
const isValidUuidString = (str) => {
|
|
@@ -38,51 +41,49 @@ const isValidUuidString = (str) => {
|
|
|
38
41
|
};
|
|
39
42
|
exports.isValidUuidString = isValidUuidString;
|
|
40
43
|
const isCharactersString = (str) => {
|
|
41
|
-
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
44
|
+
if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 1000)
|
|
42
45
|
return false;
|
|
43
46
|
return /^[\da-zA-Z _-]+$/.test(str);
|
|
44
47
|
};
|
|
45
48
|
exports.isCharactersString = isCharactersString;
|
|
46
49
|
const isNameString = (str) => {
|
|
47
|
-
if (
|
|
50
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 1000) {
|
|
48
51
|
return false;
|
|
49
52
|
}
|
|
50
53
|
return /^[A-Za-z][0-9a-zA-Z-_.,'() ]+$/.test(str.trim());
|
|
51
54
|
};
|
|
52
55
|
exports.isNameString = isNameString;
|
|
53
56
|
const isSafeSearchString = (str) => {
|
|
54
|
-
if (
|
|
57
|
+
if (typeof str !== 'string' || str.length === 0)
|
|
55
58
|
return false;
|
|
56
59
|
return /^[A-Za-z][0-9a-zA-Z\-_.,'()@ ]{1,100}$/.test(str.trim());
|
|
57
60
|
};
|
|
58
61
|
exports.isSafeSearchString = isSafeSearchString;
|
|
59
62
|
const isEmailString = (email) => {
|
|
60
|
-
if (email ===
|
|
61
|
-
typeof email !== 'string' ||
|
|
62
|
-
email.length === 0 ||
|
|
63
|
-
email.length > 1000) {
|
|
63
|
+
if (typeof email !== 'string' || email.length === 0 || email.length > 320) {
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
// Simplified safe email regex
|
|
67
|
+
const regExpEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-zA-Z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/;
|
|
68
|
+
return regExpEmail.test(email);
|
|
68
69
|
};
|
|
69
70
|
exports.isEmailString = isEmailString;
|
|
70
71
|
const isJwtString = (jwt) => {
|
|
71
|
-
if (jwt
|
|
72
|
+
if (typeof jwt !== 'string' || jwt.length === 0 || jwt.length > 8192 || jwt.trim() === '')
|
|
72
73
|
return false;
|
|
73
74
|
const jwtRegex = /^eyJ[a-zA-Z0-9-_.]+$/;
|
|
74
75
|
return jwtRegex.test(jwt);
|
|
75
76
|
};
|
|
76
77
|
exports.isJwtString = isJwtString;
|
|
77
78
|
const isPasswordString = (password) => {
|
|
78
|
-
if (
|
|
79
|
+
if (typeof password !== 'string' || password.length === 0 || password.length > 128)
|
|
79
80
|
return false;
|
|
80
81
|
const regExPassword = /^(?=.*[a-zA-Z0-9])(?=.*[!@#$%^&*_-])[a-zA-Z0-9!@#$%^&*_-]{6,32}$/;
|
|
81
82
|
return regExPassword.test(String(password));
|
|
82
83
|
};
|
|
83
84
|
exports.isPasswordString = isPasswordString;
|
|
84
85
|
const isSimplePasswordString = (password) => {
|
|
85
|
-
if (
|
|
86
|
+
if (typeof password !== 'string' || password.length === 0 || password.length > 128)
|
|
86
87
|
return false;
|
|
87
88
|
const regExPassword = /^[a-zA-Z0-9!@#$%^&*_-]{6,32}$/;
|
|
88
89
|
return regExPassword.test(String(password));
|
|
@@ -98,7 +99,7 @@ const isPasswordStringFailureMessage = (password) => {
|
|
|
98
99
|
};
|
|
99
100
|
exports.isPasswordStringFailureMessage = isPasswordStringFailureMessage;
|
|
100
101
|
const isSimplePasswordStringFailureMessage = (password) => {
|
|
101
|
-
if (!(0, exports.
|
|
102
|
+
if (!(0, exports.isSimplePasswordString)(password)) {
|
|
102
103
|
return 'Total 6 to 32 characters, numbers or !@#$%^&*_-';
|
|
103
104
|
}
|
|
104
105
|
else {
|
|
@@ -107,31 +108,34 @@ const isSimplePasswordStringFailureMessage = (password) => {
|
|
|
107
108
|
};
|
|
108
109
|
exports.isSimplePasswordStringFailureMessage = isSimplePasswordStringFailureMessage;
|
|
109
110
|
const isUsernameString = (str) => {
|
|
110
|
-
if (
|
|
111
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 200)
|
|
111
112
|
return false;
|
|
112
113
|
return /^[0-9a-zA-Z]+$/.test(str);
|
|
113
114
|
};
|
|
114
115
|
exports.isUsernameString = isUsernameString;
|
|
115
116
|
function isPhoneNumber(str) {
|
|
116
|
-
if (
|
|
117
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 20)
|
|
117
118
|
return false;
|
|
118
119
|
return /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/.test(str);
|
|
119
120
|
}
|
|
120
121
|
const isUrlSafeString = (inputString) => {
|
|
121
|
-
if (inputString
|
|
122
|
+
if (typeof inputString !== 'string' ||
|
|
123
|
+
inputString.length === 0 ||
|
|
124
|
+
inputString.length > 2048 ||
|
|
125
|
+
inputString.trim() === '')
|
|
122
126
|
return false;
|
|
123
|
-
const
|
|
124
|
-
return
|
|
127
|
+
const urlSafeRegex = /^[a-zA-Z0-9-_.]+$/;
|
|
128
|
+
return urlSafeRegex.test(inputString);
|
|
125
129
|
};
|
|
126
130
|
exports.isUrlSafeString = isUrlSafeString;
|
|
127
131
|
const isString6To24CharacterLong = (password) => {
|
|
128
|
-
if (
|
|
132
|
+
if (typeof password !== 'string' || password.length === 0)
|
|
129
133
|
return false;
|
|
130
134
|
return 6 <= password.length && password.length <= 24;
|
|
131
135
|
};
|
|
132
136
|
exports.isString6To24CharacterLong = isString6To24CharacterLong;
|
|
133
137
|
const isString6To16CharacterLong = (password) => {
|
|
134
|
-
if (
|
|
138
|
+
if (typeof password !== 'string' || password.length === 0)
|
|
135
139
|
return false;
|
|
136
140
|
return 6 <= password.length && password.length <= 16;
|
|
137
141
|
};
|
|
@@ -139,48 +143,45 @@ exports.isString6To16CharacterLong = isString6To16CharacterLong;
|
|
|
139
143
|
const isProvinceString = (inputString) => {
|
|
140
144
|
const provinces = ['on', 'qc'];
|
|
141
145
|
if ((0, exports.isNameString)(inputString)) {
|
|
142
|
-
return provinces.includes(inputString.toLowerCase());
|
|
146
|
+
return provinces.includes(inputString.toLowerCase().trim());
|
|
143
147
|
}
|
|
144
148
|
return false;
|
|
145
149
|
};
|
|
146
150
|
exports.isProvinceString = isProvinceString;
|
|
147
151
|
const isBoolValue = (inputValue) => {
|
|
148
|
-
return
|
|
152
|
+
return typeof inputValue === 'boolean';
|
|
149
153
|
};
|
|
150
154
|
exports.isBoolValue = isBoolValue;
|
|
151
155
|
const isPostalCodeString = (inputString) => {
|
|
152
156
|
const postalCodeRegex = /^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$/i;
|
|
153
157
|
if ((0, exports.isNameString)(inputString)) {
|
|
154
|
-
return postalCodeRegex.test(inputString);
|
|
158
|
+
return postalCodeRegex.test(inputString.trim());
|
|
155
159
|
}
|
|
156
160
|
return false;
|
|
157
161
|
};
|
|
158
162
|
exports.isPostalCodeString = isPostalCodeString;
|
|
159
163
|
const isSafeString = (str) => {
|
|
160
|
-
if (
|
|
164
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 10000)
|
|
161
165
|
return false;
|
|
162
|
-
return /^[\da-zA-Z-_.,#*'()
|
|
166
|
+
return /^[\da-zA-Z-_.,#*'()[\]: ]+$/.test(str);
|
|
163
167
|
};
|
|
164
168
|
exports.isSafeString = isSafeString;
|
|
165
169
|
const isInStringArray = (StringArray, inputString) => {
|
|
166
170
|
if ((0, exports.isNameString)(inputString)) {
|
|
167
|
-
return StringArray.includes(inputString.toLowerCase());
|
|
171
|
+
return StringArray.includes(inputString.toLowerCase().trim());
|
|
168
172
|
}
|
|
169
173
|
return false;
|
|
170
174
|
};
|
|
171
175
|
exports.isInStringArray = isInStringArray;
|
|
172
176
|
const isCountryCodeString = (str) => {
|
|
173
|
-
if (
|
|
177
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 4)
|
|
174
178
|
return false;
|
|
175
|
-
const
|
|
176
|
-
return
|
|
179
|
+
const countryCodeRegex = /^\+[1-9][0-9]{0,2}$/;
|
|
180
|
+
return countryCodeRegex.test(str);
|
|
177
181
|
};
|
|
178
182
|
exports.isCountryCodeString = isCountryCodeString;
|
|
179
183
|
const isValidDomainName = (domain) => {
|
|
180
|
-
if (domain ===
|
|
181
|
-
typeof domain !== 'string' ||
|
|
182
|
-
domain.length === 0 ||
|
|
183
|
-
domain.length > 253)
|
|
184
|
+
if (typeof domain !== 'string' || domain.length === 0 || domain.length > 253)
|
|
184
185
|
return false;
|
|
185
186
|
const domainRegex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/i;
|
|
186
187
|
return domainRegex.test(domain);
|
package/dist/cjs/validate.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export declare const isImageUrl: (imageUrl:
|
|
2
|
-
export declare const isInteger: (number:
|
|
3
|
-
export declare const isValidJsonString: (str:
|
|
4
|
-
export declare const isValidIntegerString: (str:
|
|
5
|
-
export declare const isValidUuidString: (str:
|
|
6
|
-
export declare const isCharactersString: (str:
|
|
7
|
-
export declare const isNameString: (str:
|
|
8
|
-
export declare const isSafeSearchString: (str:
|
|
9
|
-
export declare const isEmailString: (email:
|
|
10
|
-
export declare const isJwtString: (jwt:
|
|
11
|
-
export declare const isPasswordString: (password:
|
|
12
|
-
export declare const isSimplePasswordString: (password:
|
|
13
|
-
export declare const isPasswordStringFailureMessage: (password:
|
|
14
|
-
export declare const isSimplePasswordStringFailureMessage: (password:
|
|
15
|
-
export declare const isUsernameString: (str:
|
|
16
|
-
export declare function isPhoneNumber(str:
|
|
17
|
-
export declare const isUrlSafeString: (inputString:
|
|
18
|
-
export declare const isString6To24CharacterLong: (password:
|
|
19
|
-
export declare const isString6To16CharacterLong: (password:
|
|
20
|
-
export declare const isProvinceString: (inputString:
|
|
21
|
-
export declare const isBoolValue: (inputValue:
|
|
22
|
-
export declare const isPostalCodeString: (inputString:
|
|
23
|
-
export declare const isSafeString: (str:
|
|
24
|
-
export declare const isInStringArray: (StringArray: string
|
|
25
|
-
export declare const isCountryCodeString: (str:
|
|
26
|
-
export declare const isValidDomainName: (domain:
|
|
1
|
+
export declare const isImageUrl: (imageUrl: unknown) => boolean;
|
|
2
|
+
export declare const isInteger: (number: unknown) => boolean;
|
|
3
|
+
export declare const isValidJsonString: (str: unknown) => boolean;
|
|
4
|
+
export declare const isValidIntegerString: (str: unknown) => boolean;
|
|
5
|
+
export declare const isValidUuidString: (str: unknown) => boolean;
|
|
6
|
+
export declare const isCharactersString: (str: unknown) => boolean;
|
|
7
|
+
export declare const isNameString: (str: unknown) => boolean;
|
|
8
|
+
export declare const isSafeSearchString: (str: unknown) => boolean;
|
|
9
|
+
export declare const isEmailString: (email: unknown) => boolean;
|
|
10
|
+
export declare const isJwtString: (jwt: unknown) => boolean;
|
|
11
|
+
export declare const isPasswordString: (password: unknown) => boolean;
|
|
12
|
+
export declare const isSimplePasswordString: (password: unknown) => boolean;
|
|
13
|
+
export declare const isPasswordStringFailureMessage: (password: unknown) => "Total 6 to 32 characters, numbers and one of !@#$%^&*_-" | null;
|
|
14
|
+
export declare const isSimplePasswordStringFailureMessage: (password: unknown) => "Total 6 to 32 characters, numbers or !@#$%^&*_-" | null;
|
|
15
|
+
export declare const isUsernameString: (str: unknown) => boolean;
|
|
16
|
+
export declare function isPhoneNumber(str: unknown): boolean;
|
|
17
|
+
export declare const isUrlSafeString: (inputString: unknown) => boolean;
|
|
18
|
+
export declare const isString6To24CharacterLong: (password: unknown) => boolean;
|
|
19
|
+
export declare const isString6To16CharacterLong: (password: unknown) => boolean;
|
|
20
|
+
export declare const isProvinceString: (inputString: unknown) => boolean;
|
|
21
|
+
export declare const isBoolValue: (inputValue: unknown) => inputValue is boolean;
|
|
22
|
+
export declare const isPostalCodeString: (inputString: unknown) => boolean;
|
|
23
|
+
export declare const isSafeString: (str: unknown) => boolean;
|
|
24
|
+
export declare const isInStringArray: (StringArray: string[], inputString: unknown) => boolean;
|
|
25
|
+
export declare const isCountryCodeString: (str: unknown) => boolean;
|
|
26
|
+
export declare const isValidDomainName: (domain: unknown) => boolean;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateProperties = validateProperties;
|
|
4
4
|
// Validate the property values format.
|
|
5
|
-
const validate_1 = require("./validate");
|
|
5
|
+
const validate_1 = require("./validate.cjs");
|
|
6
6
|
function validateProperties(obj = {}) {
|
|
7
|
-
|
|
8
|
-
for (
|
|
7
|
+
const returnObj = {};
|
|
8
|
+
for (const [key, value] of Object.entries(obj || {})) {
|
|
9
9
|
switch (key) {
|
|
10
10
|
case 'first_name':
|
|
11
|
+
case 'firstName':
|
|
11
12
|
case 'username':
|
|
13
|
+
case 'new_status':
|
|
12
14
|
case 'newStatus':
|
|
13
15
|
case 'description':
|
|
14
16
|
case 'comment':
|
|
@@ -17,33 +19,49 @@ function validateProperties(obj = {}) {
|
|
|
17
19
|
case 'title':
|
|
18
20
|
case 'brand':
|
|
19
21
|
case 'short_description':
|
|
20
|
-
|
|
22
|
+
case 'shortDescription':
|
|
23
|
+
if ((0, validate_1.isNameString)(value)) {
|
|
24
|
+
returnObj[key] = value;
|
|
25
|
+
}
|
|
21
26
|
break;
|
|
22
27
|
case 'search_string':
|
|
23
28
|
case 'searchString':
|
|
24
|
-
(0, validate_1.isSafeSearchString)(value)
|
|
29
|
+
if ((0, validate_1.isSafeSearchString)(value)) {
|
|
30
|
+
returnObj[key] = value;
|
|
31
|
+
}
|
|
25
32
|
break;
|
|
26
33
|
case 'password':
|
|
27
34
|
case 'new_password':
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
case 'newPassword':
|
|
36
|
+
if ((0, validate_1.isString6To16CharacterLong)(value) && (0, validate_1.isSimplePasswordString)(value)) {
|
|
37
|
+
returnObj[key] = value;
|
|
38
|
+
}
|
|
31
39
|
break;
|
|
32
40
|
case 'strong_password':
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
case 'strongPassword':
|
|
42
|
+
if ((0, validate_1.isString6To16CharacterLong)(value) && (0, validate_1.isPasswordString)(value)) {
|
|
43
|
+
returnObj[key] = value;
|
|
44
|
+
}
|
|
36
45
|
break;
|
|
37
46
|
case 'email':
|
|
38
|
-
(0, validate_1.isEmailString)(value)
|
|
47
|
+
if ((0, validate_1.isEmailString)(value)) {
|
|
48
|
+
returnObj[key] = value;
|
|
49
|
+
}
|
|
39
50
|
break;
|
|
40
51
|
case 'phone_number':
|
|
41
|
-
|
|
52
|
+
case 'phoneNumber':
|
|
53
|
+
if ((0, validate_1.isPhoneNumber)(value)) {
|
|
54
|
+
returnObj[key] = value;
|
|
55
|
+
}
|
|
42
56
|
break;
|
|
43
57
|
case 'token':
|
|
44
58
|
case 'email_confirm_token':
|
|
59
|
+
case 'emailConfirmToken':
|
|
45
60
|
case 'verification_token':
|
|
46
|
-
|
|
61
|
+
case 'verificationToken':
|
|
62
|
+
if ((0, validate_1.isUrlSafeString)(value)) {
|
|
63
|
+
returnObj[key] = value;
|
|
64
|
+
}
|
|
47
65
|
break;
|
|
48
66
|
case 'uuid':
|
|
49
67
|
case 'item_id':
|
|
@@ -51,35 +69,59 @@ function validateProperties(obj = {}) {
|
|
|
51
69
|
case 'image_id':
|
|
52
70
|
case 'itemId':
|
|
53
71
|
case 'userId':
|
|
72
|
+
case 'imageId':
|
|
73
|
+
case 'order_id':
|
|
54
74
|
case 'orderId':
|
|
55
75
|
case 'category_id':
|
|
76
|
+
case 'categoryId':
|
|
56
77
|
case 'parent_id':
|
|
57
|
-
|
|
78
|
+
case 'parentId':
|
|
79
|
+
if ((0, validate_1.isValidUuidString)(value)) {
|
|
80
|
+
returnObj[key] = value;
|
|
81
|
+
}
|
|
58
82
|
break;
|
|
59
83
|
case 'period':
|
|
60
|
-
(0, validate_1.isCharactersString)(value)
|
|
84
|
+
if ((0, validate_1.isCharactersString)(value)) {
|
|
85
|
+
returnObj[key] = value;
|
|
86
|
+
}
|
|
61
87
|
break;
|
|
62
88
|
case 'offset_number':
|
|
89
|
+
case 'offsetNumber':
|
|
63
90
|
case 'number_of_orders':
|
|
91
|
+
case 'numberOfOrders':
|
|
64
92
|
case 'price':
|
|
65
|
-
(0, validate_1.isValidIntegerString)(value)
|
|
93
|
+
if ((0, validate_1.isValidIntegerString)(value)) {
|
|
94
|
+
returnObj[key] = value;
|
|
95
|
+
}
|
|
66
96
|
break;
|
|
67
97
|
case 'about':
|
|
68
|
-
(0, validate_1.isValidJsonString)(value)
|
|
98
|
+
if ((0, validate_1.isValidJsonString)(value)) {
|
|
99
|
+
returnObj[key] = value.trim();
|
|
100
|
+
}
|
|
69
101
|
break;
|
|
70
102
|
case 'weight':
|
|
71
103
|
case 'dimensions':
|
|
72
104
|
case 'permission':
|
|
73
|
-
(0, validate_1.isValidJsonString)(JSON.stringify(value))
|
|
105
|
+
if ((0, validate_1.isValidJsonString)(JSON.stringify(value))) {
|
|
106
|
+
returnObj[key] = value;
|
|
107
|
+
}
|
|
74
108
|
break;
|
|
75
109
|
case 'image_url':
|
|
76
|
-
|
|
110
|
+
case 'imageUrl':
|
|
111
|
+
if ((0, validate_1.isImageUrl)(value)) {
|
|
112
|
+
returnObj[key] = value;
|
|
113
|
+
}
|
|
77
114
|
break;
|
|
78
115
|
case 'domain_name':
|
|
116
|
+
case 'domainName':
|
|
79
117
|
case 'domain':
|
|
80
118
|
case 'email_domain':
|
|
119
|
+
case 'emailDomain':
|
|
81
120
|
case 'email_domain_name':
|
|
82
|
-
|
|
121
|
+
case 'emailDomainName':
|
|
122
|
+
if ((0, validate_1.isValidDomainName)(value)) {
|
|
123
|
+
returnObj[key] = value;
|
|
124
|
+
}
|
|
83
125
|
break;
|
|
84
126
|
}
|
|
85
127
|
}
|
package/dist/esm/validate.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export declare const isImageUrl: (imageUrl:
|
|
2
|
-
export declare const isInteger: (number:
|
|
3
|
-
export declare const isValidJsonString: (str:
|
|
4
|
-
export declare const isValidIntegerString: (str:
|
|
5
|
-
export declare const isValidUuidString: (str:
|
|
6
|
-
export declare const isCharactersString: (str:
|
|
7
|
-
export declare const isNameString: (str:
|
|
8
|
-
export declare const isSafeSearchString: (str:
|
|
9
|
-
export declare const isEmailString: (email:
|
|
10
|
-
export declare const isJwtString: (jwt:
|
|
11
|
-
export declare const isPasswordString: (password:
|
|
12
|
-
export declare const isSimplePasswordString: (password:
|
|
13
|
-
export declare const isPasswordStringFailureMessage: (password:
|
|
14
|
-
export declare const isSimplePasswordStringFailureMessage: (password:
|
|
15
|
-
export declare const isUsernameString: (str:
|
|
16
|
-
export declare function isPhoneNumber(str:
|
|
17
|
-
export declare const isUrlSafeString: (inputString:
|
|
18
|
-
export declare const isString6To24CharacterLong: (password:
|
|
19
|
-
export declare const isString6To16CharacterLong: (password:
|
|
20
|
-
export declare const isProvinceString: (inputString:
|
|
21
|
-
export declare const isBoolValue: (inputValue:
|
|
22
|
-
export declare const isPostalCodeString: (inputString:
|
|
23
|
-
export declare const isSafeString: (str:
|
|
24
|
-
export declare const isInStringArray: (StringArray: string
|
|
25
|
-
export declare const isCountryCodeString: (str:
|
|
26
|
-
export declare const isValidDomainName: (domain:
|
|
1
|
+
export declare const isImageUrl: (imageUrl: unknown) => boolean;
|
|
2
|
+
export declare const isInteger: (number: unknown) => boolean;
|
|
3
|
+
export declare const isValidJsonString: (str: unknown) => boolean;
|
|
4
|
+
export declare const isValidIntegerString: (str: unknown) => boolean;
|
|
5
|
+
export declare const isValidUuidString: (str: unknown) => boolean;
|
|
6
|
+
export declare const isCharactersString: (str: unknown) => boolean;
|
|
7
|
+
export declare const isNameString: (str: unknown) => boolean;
|
|
8
|
+
export declare const isSafeSearchString: (str: unknown) => boolean;
|
|
9
|
+
export declare const isEmailString: (email: unknown) => boolean;
|
|
10
|
+
export declare const isJwtString: (jwt: unknown) => boolean;
|
|
11
|
+
export declare const isPasswordString: (password: unknown) => boolean;
|
|
12
|
+
export declare const isSimplePasswordString: (password: unknown) => boolean;
|
|
13
|
+
export declare const isPasswordStringFailureMessage: (password: unknown) => "Total 6 to 32 characters, numbers and one of !@#$%^&*_-" | null;
|
|
14
|
+
export declare const isSimplePasswordStringFailureMessage: (password: unknown) => "Total 6 to 32 characters, numbers or !@#$%^&*_-" | null;
|
|
15
|
+
export declare const isUsernameString: (str: unknown) => boolean;
|
|
16
|
+
export declare function isPhoneNumber(str: unknown): boolean;
|
|
17
|
+
export declare const isUrlSafeString: (inputString: unknown) => boolean;
|
|
18
|
+
export declare const isString6To24CharacterLong: (password: unknown) => boolean;
|
|
19
|
+
export declare const isString6To16CharacterLong: (password: unknown) => boolean;
|
|
20
|
+
export declare const isProvinceString: (inputString: unknown) => boolean;
|
|
21
|
+
export declare const isBoolValue: (inputValue: unknown) => inputValue is boolean;
|
|
22
|
+
export declare const isPostalCodeString: (inputString: unknown) => boolean;
|
|
23
|
+
export declare const isSafeString: (str: unknown) => boolean;
|
|
24
|
+
export declare const isInStringArray: (StringArray: string[], inputString: unknown) => boolean;
|
|
25
|
+
export declare const isCountryCodeString: (str: unknown) => boolean;
|
|
26
|
+
export declare const isValidDomainName: (domain: unknown) => boolean;
|
package/dist/esm/validate.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export const isImageUrl = (imageUrl) => {
|
|
2
|
-
if (imageUrl === undefined ||
|
|
2
|
+
if (imageUrl === undefined ||
|
|
3
|
+
typeof imageUrl !== 'string' ||
|
|
4
|
+
imageUrl.length === 0 ||
|
|
5
|
+
imageUrl.length > 2048)
|
|
3
6
|
return false;
|
|
4
7
|
const imageUrlRegex = /^[a-zA-Z0-9-_./]+$/;
|
|
5
8
|
return imageUrlRegex.test(imageUrl);
|
|
@@ -8,20 +11,20 @@ export const isInteger = (number) => {
|
|
|
8
11
|
return Number.isInteger(number);
|
|
9
12
|
};
|
|
10
13
|
export const isValidJsonString = (str) => {
|
|
11
|
-
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
14
|
+
if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 10000)
|
|
12
15
|
return false;
|
|
13
16
|
try {
|
|
14
17
|
const json = JSON.parse(str);
|
|
15
|
-
return typeof json === 'object';
|
|
18
|
+
return typeof json === 'object' && json !== null;
|
|
16
19
|
}
|
|
17
|
-
catch
|
|
20
|
+
catch {
|
|
18
21
|
return false;
|
|
19
22
|
}
|
|
20
23
|
};
|
|
21
24
|
export const isValidIntegerString = (str) => {
|
|
22
|
-
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
25
|
+
if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 20)
|
|
23
26
|
return false;
|
|
24
|
-
return /^\d
|
|
27
|
+
return /^\d+$/.test(str);
|
|
25
28
|
};
|
|
26
29
|
export const isValidUuidString = (str) => {
|
|
27
30
|
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
@@ -29,45 +32,43 @@ export const isValidUuidString = (str) => {
|
|
|
29
32
|
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);
|
|
30
33
|
};
|
|
31
34
|
export const isCharactersString = (str) => {
|
|
32
|
-
if (str === undefined || typeof str !== 'string' || str.length === 0)
|
|
35
|
+
if (str === undefined || typeof str !== 'string' || str.length === 0 || str.length > 1000)
|
|
33
36
|
return false;
|
|
34
37
|
return /^[\da-zA-Z _-]+$/.test(str);
|
|
35
38
|
};
|
|
36
39
|
export const isNameString = (str) => {
|
|
37
|
-
if (
|
|
40
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 1000) {
|
|
38
41
|
return false;
|
|
39
42
|
}
|
|
40
43
|
return /^[A-Za-z][0-9a-zA-Z-_.,'() ]+$/.test(str.trim());
|
|
41
44
|
};
|
|
42
45
|
export const isSafeSearchString = (str) => {
|
|
43
|
-
if (
|
|
46
|
+
if (typeof str !== 'string' || str.length === 0)
|
|
44
47
|
return false;
|
|
45
48
|
return /^[A-Za-z][0-9a-zA-Z\-_.,'()@ ]{1,100}$/.test(str.trim());
|
|
46
49
|
};
|
|
47
50
|
export const isEmailString = (email) => {
|
|
48
|
-
if (email ===
|
|
49
|
-
typeof email !== 'string' ||
|
|
50
|
-
email.length === 0 ||
|
|
51
|
-
email.length > 1000) {
|
|
51
|
+
if (typeof email !== 'string' || email.length === 0 || email.length > 320) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Simplified safe email regex
|
|
55
|
+
const regExpEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-zA-Z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/;
|
|
56
|
+
return regExpEmail.test(email);
|
|
56
57
|
};
|
|
57
58
|
export const isJwtString = (jwt) => {
|
|
58
|
-
if (jwt
|
|
59
|
+
if (typeof jwt !== 'string' || jwt.length === 0 || jwt.length > 8192 || jwt.trim() === '')
|
|
59
60
|
return false;
|
|
60
61
|
const jwtRegex = /^eyJ[a-zA-Z0-9-_.]+$/;
|
|
61
62
|
return jwtRegex.test(jwt);
|
|
62
63
|
};
|
|
63
64
|
export const isPasswordString = (password) => {
|
|
64
|
-
if (
|
|
65
|
+
if (typeof password !== 'string' || password.length === 0 || password.length > 128)
|
|
65
66
|
return false;
|
|
66
67
|
const regExPassword = /^(?=.*[a-zA-Z0-9])(?=.*[!@#$%^&*_-])[a-zA-Z0-9!@#$%^&*_-]{6,32}$/;
|
|
67
68
|
return regExPassword.test(String(password));
|
|
68
69
|
};
|
|
69
70
|
export const isSimplePasswordString = (password) => {
|
|
70
|
-
if (
|
|
71
|
+
if (typeof password !== 'string' || password.length === 0 || password.length > 128)
|
|
71
72
|
return false;
|
|
72
73
|
const regExPassword = /^[a-zA-Z0-9!@#$%^&*_-]{6,32}$/;
|
|
73
74
|
return regExPassword.test(String(password));
|
|
@@ -81,7 +82,7 @@ export const isPasswordStringFailureMessage = (password) => {
|
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
export const isSimplePasswordStringFailureMessage = (password) => {
|
|
84
|
-
if (!
|
|
85
|
+
if (!isSimplePasswordString(password)) {
|
|
85
86
|
return 'Total 6 to 32 characters, numbers or !@#$%^&*_-';
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
@@ -89,70 +90,70 @@ export const isSimplePasswordStringFailureMessage = (password) => {
|
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
92
|
export const isUsernameString = (str) => {
|
|
92
|
-
if (
|
|
93
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 200)
|
|
93
94
|
return false;
|
|
94
95
|
return /^[0-9a-zA-Z]+$/.test(str);
|
|
95
96
|
};
|
|
96
97
|
export function isPhoneNumber(str) {
|
|
97
|
-
if (
|
|
98
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 20)
|
|
98
99
|
return false;
|
|
99
100
|
return /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/.test(str);
|
|
100
101
|
}
|
|
101
102
|
export const isUrlSafeString = (inputString) => {
|
|
102
|
-
if (inputString
|
|
103
|
+
if (typeof inputString !== 'string' ||
|
|
104
|
+
inputString.length === 0 ||
|
|
105
|
+
inputString.length > 2048 ||
|
|
106
|
+
inputString.trim() === '')
|
|
103
107
|
return false;
|
|
104
|
-
const
|
|
105
|
-
return
|
|
108
|
+
const urlSafeRegex = /^[a-zA-Z0-9-_.]+$/;
|
|
109
|
+
return urlSafeRegex.test(inputString);
|
|
106
110
|
};
|
|
107
111
|
export const isString6To24CharacterLong = (password) => {
|
|
108
|
-
if (
|
|
112
|
+
if (typeof password !== 'string' || password.length === 0)
|
|
109
113
|
return false;
|
|
110
114
|
return 6 <= password.length && password.length <= 24;
|
|
111
115
|
};
|
|
112
116
|
export const isString6To16CharacterLong = (password) => {
|
|
113
|
-
if (
|
|
117
|
+
if (typeof password !== 'string' || password.length === 0)
|
|
114
118
|
return false;
|
|
115
119
|
return 6 <= password.length && password.length <= 16;
|
|
116
120
|
};
|
|
117
121
|
export const isProvinceString = (inputString) => {
|
|
118
122
|
const provinces = ['on', 'qc'];
|
|
119
123
|
if (isNameString(inputString)) {
|
|
120
|
-
return provinces.includes(inputString.toLowerCase());
|
|
124
|
+
return provinces.includes(inputString.toLowerCase().trim());
|
|
121
125
|
}
|
|
122
126
|
return false;
|
|
123
127
|
};
|
|
124
128
|
export const isBoolValue = (inputValue) => {
|
|
125
|
-
return
|
|
129
|
+
return typeof inputValue === 'boolean';
|
|
126
130
|
};
|
|
127
131
|
export const isPostalCodeString = (inputString) => {
|
|
128
132
|
const postalCodeRegex = /^(?!.*[DFIOQU])[A-VXY][0-9][A-Z] ?[0-9][A-Z][0-9]$/i;
|
|
129
133
|
if (isNameString(inputString)) {
|
|
130
|
-
return postalCodeRegex.test(inputString);
|
|
134
|
+
return postalCodeRegex.test(inputString.trim());
|
|
131
135
|
}
|
|
132
136
|
return false;
|
|
133
137
|
};
|
|
134
138
|
export const isSafeString = (str) => {
|
|
135
|
-
if (
|
|
139
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 10000)
|
|
136
140
|
return false;
|
|
137
|
-
return /^[\da-zA-Z-_.,#*'()
|
|
141
|
+
return /^[\da-zA-Z-_.,#*'()[\]: ]+$/.test(str);
|
|
138
142
|
};
|
|
139
143
|
export const isInStringArray = (StringArray, inputString) => {
|
|
140
144
|
if (isNameString(inputString)) {
|
|
141
|
-
return StringArray.includes(inputString.toLowerCase());
|
|
145
|
+
return StringArray.includes(inputString.toLowerCase().trim());
|
|
142
146
|
}
|
|
143
147
|
return false;
|
|
144
148
|
};
|
|
145
149
|
export const isCountryCodeString = (str) => {
|
|
146
|
-
if (
|
|
150
|
+
if (typeof str !== 'string' || str.length === 0 || str.length > 4)
|
|
147
151
|
return false;
|
|
148
|
-
const
|
|
149
|
-
return
|
|
152
|
+
const countryCodeRegex = /^\+[1-9][0-9]{0,2}$/;
|
|
153
|
+
return countryCodeRegex.test(str);
|
|
150
154
|
};
|
|
151
155
|
export const isValidDomainName = (domain) => {
|
|
152
|
-
if (domain ===
|
|
153
|
-
typeof domain !== 'string' ||
|
|
154
|
-
domain.length === 0 ||
|
|
155
|
-
domain.length > 253)
|
|
156
|
+
if (typeof domain !== 'string' || domain.length === 0 || domain.length > 253)
|
|
156
157
|
return false;
|
|
157
158
|
const domainRegex = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/i;
|
|
158
159
|
return domainRegex.test(domain);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Validate the property values format.
|
|
2
2
|
import { isEmailString, isPhoneNumber, isUrlSafeString, isValidUuidString, isSimplePasswordString, isPasswordString, isString6To16CharacterLong, isNameString, isSafeSearchString, isCharactersString, isValidIntegerString, isValidJsonString, isImageUrl, isValidDomainName, } from './validate';
|
|
3
3
|
export function validateProperties(obj = {}) {
|
|
4
|
-
|
|
5
|
-
for (
|
|
4
|
+
const returnObj = {};
|
|
5
|
+
for (const [key, value] of Object.entries(obj || {})) {
|
|
6
6
|
switch (key) {
|
|
7
7
|
case 'first_name':
|
|
8
|
+
case 'firstName':
|
|
8
9
|
case 'username':
|
|
10
|
+
case 'new_status':
|
|
9
11
|
case 'newStatus':
|
|
10
12
|
case 'description':
|
|
11
13
|
case 'comment':
|
|
@@ -14,33 +16,49 @@ export function validateProperties(obj = {}) {
|
|
|
14
16
|
case 'title':
|
|
15
17
|
case 'brand':
|
|
16
18
|
case 'short_description':
|
|
17
|
-
|
|
19
|
+
case 'shortDescription':
|
|
20
|
+
if (isNameString(value)) {
|
|
21
|
+
returnObj[key] = value;
|
|
22
|
+
}
|
|
18
23
|
break;
|
|
19
24
|
case 'search_string':
|
|
20
25
|
case 'searchString':
|
|
21
|
-
isSafeSearchString(value)
|
|
26
|
+
if (isSafeSearchString(value)) {
|
|
27
|
+
returnObj[key] = value;
|
|
28
|
+
}
|
|
22
29
|
break;
|
|
23
30
|
case 'password':
|
|
24
31
|
case 'new_password':
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
case 'newPassword':
|
|
33
|
+
if (isString6To16CharacterLong(value) && isSimplePasswordString(value)) {
|
|
34
|
+
returnObj[key] = value;
|
|
35
|
+
}
|
|
28
36
|
break;
|
|
29
37
|
case 'strong_password':
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
case 'strongPassword':
|
|
39
|
+
if (isString6To16CharacterLong(value) && isPasswordString(value)) {
|
|
40
|
+
returnObj[key] = value;
|
|
41
|
+
}
|
|
33
42
|
break;
|
|
34
43
|
case 'email':
|
|
35
|
-
isEmailString(value)
|
|
44
|
+
if (isEmailString(value)) {
|
|
45
|
+
returnObj[key] = value;
|
|
46
|
+
}
|
|
36
47
|
break;
|
|
37
48
|
case 'phone_number':
|
|
38
|
-
|
|
49
|
+
case 'phoneNumber':
|
|
50
|
+
if (isPhoneNumber(value)) {
|
|
51
|
+
returnObj[key] = value;
|
|
52
|
+
}
|
|
39
53
|
break;
|
|
40
54
|
case 'token':
|
|
41
55
|
case 'email_confirm_token':
|
|
56
|
+
case 'emailConfirmToken':
|
|
42
57
|
case 'verification_token':
|
|
43
|
-
|
|
58
|
+
case 'verificationToken':
|
|
59
|
+
if (isUrlSafeString(value)) {
|
|
60
|
+
returnObj[key] = value;
|
|
61
|
+
}
|
|
44
62
|
break;
|
|
45
63
|
case 'uuid':
|
|
46
64
|
case 'item_id':
|
|
@@ -48,35 +66,59 @@ export function validateProperties(obj = {}) {
|
|
|
48
66
|
case 'image_id':
|
|
49
67
|
case 'itemId':
|
|
50
68
|
case 'userId':
|
|
69
|
+
case 'imageId':
|
|
70
|
+
case 'order_id':
|
|
51
71
|
case 'orderId':
|
|
52
72
|
case 'category_id':
|
|
73
|
+
case 'categoryId':
|
|
53
74
|
case 'parent_id':
|
|
54
|
-
|
|
75
|
+
case 'parentId':
|
|
76
|
+
if (isValidUuidString(value)) {
|
|
77
|
+
returnObj[key] = value;
|
|
78
|
+
}
|
|
55
79
|
break;
|
|
56
80
|
case 'period':
|
|
57
|
-
isCharactersString(value)
|
|
81
|
+
if (isCharactersString(value)) {
|
|
82
|
+
returnObj[key] = value;
|
|
83
|
+
}
|
|
58
84
|
break;
|
|
59
85
|
case 'offset_number':
|
|
86
|
+
case 'offsetNumber':
|
|
60
87
|
case 'number_of_orders':
|
|
88
|
+
case 'numberOfOrders':
|
|
61
89
|
case 'price':
|
|
62
|
-
isValidIntegerString(value)
|
|
90
|
+
if (isValidIntegerString(value)) {
|
|
91
|
+
returnObj[key] = value;
|
|
92
|
+
}
|
|
63
93
|
break;
|
|
64
94
|
case 'about':
|
|
65
|
-
isValidJsonString(value)
|
|
95
|
+
if (isValidJsonString(value)) {
|
|
96
|
+
returnObj[key] = value.trim();
|
|
97
|
+
}
|
|
66
98
|
break;
|
|
67
99
|
case 'weight':
|
|
68
100
|
case 'dimensions':
|
|
69
101
|
case 'permission':
|
|
70
|
-
isValidJsonString(JSON.stringify(value))
|
|
102
|
+
if (isValidJsonString(JSON.stringify(value))) {
|
|
103
|
+
returnObj[key] = value;
|
|
104
|
+
}
|
|
71
105
|
break;
|
|
72
106
|
case 'image_url':
|
|
73
|
-
|
|
107
|
+
case 'imageUrl':
|
|
108
|
+
if (isImageUrl(value)) {
|
|
109
|
+
returnObj[key] = value;
|
|
110
|
+
}
|
|
74
111
|
break;
|
|
75
112
|
case 'domain_name':
|
|
113
|
+
case 'domainName':
|
|
76
114
|
case 'domain':
|
|
77
115
|
case 'email_domain':
|
|
116
|
+
case 'emailDomain':
|
|
78
117
|
case 'email_domain_name':
|
|
79
|
-
|
|
118
|
+
case 'emailDomainName':
|
|
119
|
+
if (isValidDomainName(value)) {
|
|
120
|
+
returnObj[key] = value;
|
|
121
|
+
}
|
|
80
122
|
break;
|
|
81
123
|
}
|
|
82
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carecard/validate-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Validate functions",
|
|
6
6
|
"license": "ISC",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"types": "./dist/esm/index.d.ts",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
+
"types": "./dist/esm/index.d.ts",
|
|
21
22
|
"import": "./dist/esm/index.js",
|
|
22
|
-
"require": "./dist/cjs/index.cjs"
|
|
23
|
-
"types": "./dist/esm/index.d.ts"
|
|
23
|
+
"require": "./dist/cjs/index.cjs"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
@@ -34,14 +34,27 @@
|
|
|
34
34
|
"format": "prettier --write .",
|
|
35
35
|
"format:check": "prettier --check .",
|
|
36
36
|
"lint": "eslint",
|
|
37
|
+
"lint:fix": "eslint --fix",
|
|
37
38
|
"prepare": "husky"
|
|
38
39
|
},
|
|
40
|
+
"lint-staged": {
|
|
41
|
+
"*.{js,ts,cjs}": [
|
|
42
|
+
"eslint --fix",
|
|
43
|
+
"prettier --write"
|
|
44
|
+
],
|
|
45
|
+
"*.{json,md,yml}": [
|
|
46
|
+
"prettier --write"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
39
49
|
"devDependencies": {
|
|
50
|
+
"@eslint/js": "^9.39.2",
|
|
40
51
|
"@types/jest": "30.0.0",
|
|
41
52
|
"@types/node": "25.0.3",
|
|
42
53
|
"eslint": "9.39.2",
|
|
54
|
+
"globals": "^17.1.0",
|
|
43
55
|
"husky": "9.1.7",
|
|
44
56
|
"jest": "30.2.0",
|
|
57
|
+
"lint-staged": "^16.2.7",
|
|
45
58
|
"prettier": "3.7.4",
|
|
46
59
|
"ts-jest": "29.4.6",
|
|
47
60
|
"typescript": "5.9.3",
|