Skip to content

[Adonis 5] Route Validator #1435

Answered by fnoquiq
Melchyore asked this question in Help
Aug 10, 2020 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hey, validations can be done on controllers through the request context

import StoreValidator from 'App/Validators/userStore'

export default class UsersController {
  public async store({ request }: HttpContextContract) {
    const { username, password } = await request.validate(StoreValidator)

    const user = await User.create({
      username,
      password,
    })

    return user
  }
}

You can find the documentation here

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Melchyore
Comment options

Answer selected by Melchyore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants