@excofy/utils 2.3.0 → 2.3.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.
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/src/helpers/validator.ts +3 -7
package/dist/index.cjs
CHANGED
|
@@ -234,8 +234,6 @@ function createValidator() {
|
|
|
234
234
|
isValidType = typeof value === "object" && value !== null && !Array.isArray(value);
|
|
235
235
|
} else if (type === "file") {
|
|
236
236
|
isValidType = value instanceof File;
|
|
237
|
-
} else if (type === "base64") {
|
|
238
|
-
isValidType = typeof value === "string" && !!value.match(/^data:([A-Za-z-+\/]+);base64,([A-Za-z0-9+/=]+)$/);
|
|
239
237
|
} else if (type === "date") {
|
|
240
238
|
isValidType = typeof value === "string" && !Number.isNaN(new Date(value).getTime());
|
|
241
239
|
} else {
|
|
@@ -259,7 +257,9 @@ function createValidator() {
|
|
|
259
257
|
current.pushError(message);
|
|
260
258
|
return validator;
|
|
261
259
|
}
|
|
262
|
-
const match = value.match(
|
|
260
|
+
const match = value.match(
|
|
261
|
+
/^data:([A-Za-z-+\/]+);(?:charset=utf-8;)?base64,/
|
|
262
|
+
);
|
|
263
263
|
if (!match) {
|
|
264
264
|
current.pushError(message);
|
|
265
265
|
return validator;
|
package/dist/index.d.cts
CHANGED
|
@@ -13,7 +13,7 @@ type TMessage = {
|
|
|
13
13
|
};
|
|
14
14
|
type TValue = string | number | boolean | File | object | null | undefined;
|
|
15
15
|
type TInputValue = TValue;
|
|
16
|
-
type TTypes = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file' | '
|
|
16
|
+
type TTypes = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file' | 'date';
|
|
17
17
|
interface IInputErrors {
|
|
18
18
|
[key: string]: TMessage[] | IInputErrors[];
|
|
19
19
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type TMessage = {
|
|
|
13
13
|
};
|
|
14
14
|
type TValue = string | number | boolean | File | object | null | undefined;
|
|
15
15
|
type TInputValue = TValue;
|
|
16
|
-
type TTypes = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file' | '
|
|
16
|
+
type TTypes = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'file' | 'date';
|
|
17
17
|
interface IInputErrors {
|
|
18
18
|
[key: string]: TMessage[] | IInputErrors[];
|
|
19
19
|
}
|
package/dist/index.js
CHANGED
|
@@ -196,8 +196,6 @@ function createValidator() {
|
|
|
196
196
|
isValidType = typeof value === "object" && value !== null && !Array.isArray(value);
|
|
197
197
|
} else if (type === "file") {
|
|
198
198
|
isValidType = value instanceof File;
|
|
199
|
-
} else if (type === "base64") {
|
|
200
|
-
isValidType = typeof value === "string" && !!value.match(/^data:([A-Za-z-+\/]+);base64,([A-Za-z0-9+/=]+)$/);
|
|
201
199
|
} else if (type === "date") {
|
|
202
200
|
isValidType = typeof value === "string" && !Number.isNaN(new Date(value).getTime());
|
|
203
201
|
} else {
|
|
@@ -221,7 +219,9 @@ function createValidator() {
|
|
|
221
219
|
current.pushError(message);
|
|
222
220
|
return validator;
|
|
223
221
|
}
|
|
224
|
-
const match = value.match(
|
|
222
|
+
const match = value.match(
|
|
223
|
+
/^data:([A-Za-z-+\/]+);(?:charset=utf-8;)?base64,/
|
|
224
|
+
);
|
|
225
225
|
if (!match) {
|
|
226
226
|
current.pushError(message);
|
|
227
227
|
return validator;
|
package/package.json
CHANGED
package/src/helpers/validator.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isValidCNPJ, isValidCPF } from './document';
|
|
2
|
-
import { fileUtils } from './file';
|
|
3
2
|
import { sanitizeValue, type AllowedTag } from './sanitize';
|
|
4
3
|
import { video } from './video';
|
|
5
4
|
|
|
@@ -13,7 +12,6 @@ type TTypes =
|
|
|
13
12
|
| 'object'
|
|
14
13
|
| 'array'
|
|
15
14
|
| 'file'
|
|
16
|
-
| 'base64'
|
|
17
15
|
| 'date';
|
|
18
16
|
|
|
19
17
|
interface IInputErrors {
|
|
@@ -143,10 +141,6 @@ export function createValidator<
|
|
|
143
141
|
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
144
142
|
} else if (type === 'file') {
|
|
145
143
|
isValidType = value instanceof File;
|
|
146
|
-
} else if (type === 'base64') {
|
|
147
|
-
isValidType =
|
|
148
|
-
typeof value === 'string' &&
|
|
149
|
-
!!value.match(/^data:([A-Za-z-+\/]+);base64,([A-Za-z0-9+/=]+)$/);
|
|
150
144
|
} else if (type === 'date') {
|
|
151
145
|
isValidType =
|
|
152
146
|
typeof value === 'string' && !Number.isNaN(new Date(value).getTime());
|
|
@@ -187,7 +181,9 @@ export function createValidator<
|
|
|
187
181
|
return validator;
|
|
188
182
|
}
|
|
189
183
|
|
|
190
|
-
const match = value.match(
|
|
184
|
+
const match = value.match(
|
|
185
|
+
/^data:([A-Za-z-+\/]+);(?:charset=utf-8;)?base64,/
|
|
186
|
+
);
|
|
191
187
|
if (!match) {
|
|
192
188
|
current.pushError(message);
|
|
193
189
|
return validator;
|