mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-19 06:21:35 +01:00
Working on new features
This commit is contained in:
22
app/Validators/users/UserStoreValidator.ts
Normal file
22
app/Validators/users/UserStoreValidator.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
||||
|
||||
export default class UserStoreValidator {
|
||||
constructor (private ctx: HttpContextContract) {
|
||||
}
|
||||
|
||||
public schema = schema.create({
|
||||
email: schema.string({ trim: true, escape: true }, [
|
||||
rules.email(),
|
||||
rules.required(),
|
||||
rules.unique({table: 'users', column: 'email'})
|
||||
])
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !',
|
||||
'email.email': 'L\'adresse mail doit être valide !',
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user