Closed ndianabasi closed 1 year ago
Isn't it working correctly? I will use some absolute numbers to make the conversation easy to understand.
rule.before(2, 'years')
says, the date should be before "12th May, 2021". As per this rule:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing since no answer from issue reporter.
The
before
rule seems not to be validating properly. And I've traced the issue to this line: https://github.com/adonisjs/validator/blob/aded92080371ea5c12070236e2b159cb07a1c264/src/Validations/date/helpers/offset.ts#L33The duration should be added to the current date before checking if the provided date is before the maximum allowable date.
Package version
"@adonisjs/core": "^5.9.0"
Node.js and npm version
Node v14.21.1 NPM v9.1.2
Sample Code (to reproduce the issue)
This is the sample of the request made:
This is the validation schema:
And this is the response:
As seen, the compiled date for the
before
arg is 2 years behind.Changing https://github.com/adonisjs/validator/blob/aded92080371ea5c12070236e2b159cb07a1c264/src/Validations/date/helpers/offset.ts#L33 to
plus
fixes the issue.