Skip to content

Commit fe1ed66

Browse files
author
Marcos Martins
committed
validacao de timezone sem milissegundos
1 parent 302d9b3 commit fe1ed66

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/validation/Validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export class Validator {
333333
* Checks if a given value is a ISOString date.
334334
*/
335335
isDateString(value: any): boolean {
336-
const regex = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+Z?/g;
336+
const regex = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d(\.\d+)?Z?/g;
337337
return this.isString(value) && regex.test(value);
338338
}
339339

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ describe("IsString", function() {
568568

569569
describe.only("IsDateString", function() {
570570

571-
const validValues = ["2017-06-06T17:04:42.081Z", "2017-06-06T17:04:42.081"];
571+
const validValues = ["2017-06-06T17:04:42.081Z", "2017-06-06T17:04:42.081", "2017-06-06T17:04:42", "2017-06-06T17:04:42Z"];
572572
const invalidValues = [
573573
true,
574574
false,

0 commit comments

Comments
 (0)