Validator
Explore how to validate user input using the AdonisJs validator. This lesson guides you through creating validation rules for username and email, handling errors, and integrating validation into routes and controllers for secure form submissions.
We'll cover the following...
We'll cover the following...
The validation provider in AdonisJs is used to validate user input. Let’s create a form to submit the username and email and see how we can use the validator provider to check the validity of the user input and display errors.
Using the validation provider
'use strict'
class TestController {
getForm({ view }) {
return view.render('form')
}
postForm() {
return 'Form submitted!'
}
}
module.exports = TestControllerPress Run and wait for the output to be displayed in the Output tab. You will see a form in which username ...