Skip to content

Commit 7467a7f

Browse files
committed
code review improvement
1 parent 1a94593 commit 7467a7f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/introspection/DateType.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { GraphQLScalarType, GraphQLError } from 'graphql';
22
import { Kind } from 'graphql/language';
33

4+
const ISO_DATE_STRING_PATTERN = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
5+
46
export const isISODateString = (value) => {
57
if (typeof value !== 'string') return false;
6-
if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(value)) return false;
8+
if (!ISO_DATE_STRING_PATTERN.test(value)) return false;
79
const d = new Date(value);
810
return d.toISOString() === value;
911
};

0 commit comments

Comments
 (0)