poppinss / indicative

Indicative is a simple yet powerful data validator for Node.js and browsers. It makes it so simple to write async validations on nested set of data.
https://indicative.adonisjs.com/
MIT License
417 stars 52 forks source link

Validation failed for dates with a timezone including a + (eg +02:00) #261

Closed juanvillegas closed 4 years ago

juanvillegas commented 4 years ago

Package version

^7.4.4

Node.js and npm version

12.14.1 6.14.2

Sample Code (to reproduce the issue)

Trying to validate a date using the date rule and feeding ISO8601-valid strings in the following style: 2020-07-24T21:42:04+02:00 2020-07-24T21:42:04-02:00

When we include a positive offset (eg +02:00, +04:00), it doesn't work and displays the error below:

date validation failed on startDate (startDate is my field name)

If we use a negative offset, it works. If we don't use an offset, it works. If we pass the Z (00:00), it works.

So the following throws an error:

These work as expected:

Creating a JS date works (new Date("2020-07-23T23:30:45+02:00")), so the rule is expected to accept positive offsets. Am I doing something wrong?

juanvillegas commented 4 years ago

btw, I have also tried using the dateFormat rule with the following format: YYYY-MM-DDTHH:mm:ssZ and I got the same results: it doesn't accept positive offsets.