mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-26 17:40:27 +01:00
Rename Guestbook
This commit is contained in:
24
app/Validators/guestbook/StoreValidator.ts
Normal file
24
app/Validators/guestbook/StoreValidator.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
||||
|
||||
export default class StoreValidator {
|
||||
constructor (private ctx: HttpContextContract) {
|
||||
}
|
||||
|
||||
public schema = schema.create({
|
||||
user_id: schema.number( [
|
||||
rules.required(),
|
||||
rules.unique({table: 'golden_messages', column: 'user_id'}),
|
||||
rules.exists({ table: 'users', column: 'id'})
|
||||
]),
|
||||
message: schema.string({}, [
|
||||
rules.required()
|
||||
])
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !',
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user