We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a94593 commit 7467a7fCopy full SHA for 7467a7f
src/introspection/DateType.js
@@ -1,9 +1,11 @@
1
import { GraphQLScalarType, GraphQLError } from 'graphql';
2
import { Kind } from 'graphql/language';
3
4
+const ISO_DATE_STRING_PATTERN = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
5
+
6
export const isISODateString = (value) => {
7
if (typeof value !== 'string') return false;
- 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;
9
const d = new Date(value);
10
return d.toISOString() === value;
11
};
0 commit comments