Skip to content

Commit 2012d72

Browse files
authoredMar 26, 2020
fix: accept negative timezone in isDateString (#564)
Close #565
1 parent 84680ad commit 2012d72

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎src/validation/Validator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export class Validator {
402402
* Checks if a given value is a ISOString date.
403403
*/
404404
isDateString(value: unknown): boolean {
405-
const regex = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|\+[0-2]\d(?:\:[0-5]\d)?)?$/g;
405+
const regex = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[\+\-][0-2]\d(?:\:[0-5]\d)?)?$/g;
406406
return this.isString(value) && regex.test(value);
407407
}
408408

‎test/functional/validation-functions-and-decorators.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ describe("IsDateString", function() {
729729
"2018-01-04T08:15:30Z",
730730
"2018-01-04T08:15:30+04:00",
731731
"2018-01-04T08:15:30+04",
732+
"2020-03-26T11:00:01-03:00",
733+
"2020-03-26T11:00:01-03",
732734
];
733735
const invalidValues = [
734736
true,

0 commit comments

Comments
 (0)
Please sign in to comment.