mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 12:14:33 +01:00
22 lines
540 B
TypeScript
22 lines
540 B
TypeScript
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({
|
|
email: schema.string({ trim: true }, [
|
|
rules.email(),
|
|
rules.unique({table: 'subscribers', column: 'email'})
|
|
]),
|
|
name: schema.string()
|
|
})
|
|
|
|
public cacheKey = this.ctx.routeKey
|
|
|
|
public messages = {
|
|
required: 'Le champ {{field}} doit être valide !',
|
|
}
|
|
}
|