Closed mastermunj closed 3 years ago
The refs
are used incorrectly. You don't have to read the value property from it. It should be this.refs.maximumLimit
Also, I see that the range
method doesn't accept the range at all. Is range dynamic in your case, meaning it changes depending upon the request?
The
refs
are used incorrectly. You don't have to read the value property from it. It should bethis.refs.maximumLimit
If I use this.refs.maximumLimit
, I get following typescript error.
Argument of type 'SchemaRef<unknown>' is not assignable to parameter of type 'number'.
Also, I see that the
range
method doesn't accept the range at all. Is range dynamic in your case, meaning it changes depending upon the request?
Yes, the range changes depending on the current value passed for maximumLimit
.
Hi @thetutlage I am facing similar issue with maxLength rule as well. There also I need to pass length based on the value of another parameter.
Any suggestions for a workaround for both range and maxLength?
For now turning of the schema caching is the way to go. I will add support for using refs
for the maxLength argument as well.
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.
Will work on it
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.
Hi @thetutlage Is this still part of plan? This one is closed of no-activity so might get missed.
Hi,
While using
rules.range
withrefs
andcacheKey
, the validation does not work properly.Package version
@adonisjs/validator@8.2.0
Node.js and npm version
Node: 14.15.1 NPM: 6.14.9
Sample Code (to reproduce the issue)
Run following commands in sequence and see the error message:
Command 1
Expected Output
Command 2
Expected Output
Actual Output
Issue
The validation still runs with maximumLimit as 60000 rather than 80000 which is the update value passed.
Cache
When cache is disabled, by commenting this line, the validation works as expected.
BONUS (a sample repo to reproduce the issue)
https://github.com/mastermunj/adonis-range-issue