@sprucelabs/schema 29.2.1 → 29.2.2
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.
|
@@ -33,13 +33,17 @@ export function validateDateValue(options) {
|
|
|
33
33
|
if (typeof value === 'number' || value instanceof Date) {
|
|
34
34
|
return [];
|
|
35
35
|
}
|
|
36
|
-
else {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
friendlyMessage: `This doesn't look like a date to me!`,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
36
|
+
else if (typeof value === 'string') {
|
|
37
|
+
const date = new Date(value);
|
|
38
|
+
if (date.toString() !== 'Invalid Date') {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
44
41
|
}
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
name,
|
|
45
|
+
code: 'INVALID_PARAMETER',
|
|
46
|
+
friendlyMessage: `This doesn't look like a date to me!`,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
45
49
|
}
|
|
@@ -40,14 +40,18 @@ function validateDateValue(options) {
|
|
|
40
40
|
if (typeof value === 'number' || value instanceof Date) {
|
|
41
41
|
return [];
|
|
42
42
|
}
|
|
43
|
-
else {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
friendlyMessage: `This doesn't look like a date to me!`,
|
|
49
|
-
},
|
|
50
|
-
];
|
|
43
|
+
else if (typeof value === 'string') {
|
|
44
|
+
const date = new Date(value);
|
|
45
|
+
if (date.toString() !== 'Invalid Date') {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
51
48
|
}
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
name,
|
|
52
|
+
code: 'INVALID_PARAMETER',
|
|
53
|
+
friendlyMessage: `This doesn't look like a date to me!`,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
52
56
|
}
|
|
53
57
|
exports.validateDateValue = validateDateValue;
|