Skip to content

Commit

Permalink
fix(primitives): fix dateTime regex
Browse files Browse the repository at this point in the history
  • Loading branch information
tangdrew committed Feb 23, 2019
1 parent 460f832 commit 9f1cc2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/primitives/src/R4/dateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import { Type, success, failure, identity } from "io-ts";

// TODO: This regex seems incorrect as well
const DATE_TIME_REGEX = /([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)/;
const DATE_TIME_REGEX = /([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?/;

export class DateTimeType extends Type<string> {
readonly _tag: "DateTimeType" = "DateTimeType";
Expand Down
3 changes: 1 addition & 2 deletions packages/primitives/test/R4/dateTime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ describe("DateTimeType", () => {
assertSuccess(T.decode("2017-01-01T00:00:00.000Z"));
});

// TODO: Improve regex so this passes
xit("should succeed validating a partial dateTime", () => {
it("should succeed validating a partial dateTime", () => {
const T = dateTime;
assertSuccess(T.decode("2017"));
});
Expand Down

0 comments on commit 9f1cc2a

Please sign in to comment.