I want to use validation method on resources
.post('users', 'UserController.store')
.validator('StoreUser')
something like this
Route.resource('users', 'UserController')
.validator('StoreUser')
on store method, is it possible to add this feature in future ?
But how do u which method will be validated by adding validator on the resource?
only on post or put
But
post and put?post and which are for put?I think that its very common that for some resource you need validation rules, so if you have such cool validation method validate and you cant use it on resources then you must choose to use validation inside controller or not to use resource and describe every route separatly, is it possible to extend this method for something like this and to use it on Route.resource() ?
.validate({
store: 'StoreUser',
update: 'UpdateUser'
})
This syntax makes sense, will add support for it
The syntax is as follows
Route
.resource('users', 'UserController')
.validator(new Map([
['users.store', 'StoreUser'],
['users.update', 'UpdateUser']
]))
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
Added in https://github.com/adonisjs/adonis-validation-provider/commit/d58e57c5e85c97491d2f3c4b4d2d696f4e603091
The syntax is as follows