AdonisJS - Using Validators with resource routes
January 10, 2020
First, install the Validator using the adonis command:
adonis install @adonisjs/validtor
Create a resource route
adonis make:controller PostController --resource
Define the route in start/route.js
//..Route.resource("posts", "PostController")//..
Now, we can make a Validator for /posts/store
adonis make:validator StorePost
This will create a validator in /app/Validators.
Finally, To define a validator for a specific route in the definition, do something like this:
//..Route.resource("posts", "PostController").validator([[["store", "StoreUser"]]])//..
PSSS: I want this as short as it can while still answering question regarding the final code. 🥂
Edit on githubTweet