-
Hi, In the previous version (i.e 4.1), we were able to use Route Validator, but now, it seems that the validator method does not exist anymore in the Route class, is it intended? If yes, then can we create a validator class? If yes, how can we achieve that? |
Beta Was this translation helpful? Give feedback.
Answered by
fnoquiq
Aug 10, 2020
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Melchyore
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, validations can be done on controllers through the request context
You can find the documentation here