Is there a way to bind the route parameter to satisfy a specific regexp? For example, in Laravel, we can write Route::get('user/{id}')->where('id', '[0-9]+') to allow only numeric values as id.
I tried, in Adonis v4, to use .where('id', '[0-9]+') after the route but obviously it doesn't work.
There is no .where method, but you can define the regex inline.
Route.get('user/:id([0-9]+)', ({ params }) => params.id)
Oh, thank you! I have another question about the integration of eslint with adonis. The goal is to throw an error in the app (localhost:3333, not only on the console) if the lint fails. Before I open another issue, is that possible? At this time, with some edits on the package.json and the module npm-run-all I can check real-time the lint, but the errors appear only in the terminal.
Maybe you can ask this question on the forum. https://forum.adonisjs.com/
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
There is no
.wheremethod, but you can define the regex inline.