mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-23 16:30:27 +01:00
initital commit
This commit is contained in:
21
app/Validators/subscriber/StoreValidator.ts
Normal file
21
app/Validators/subscriber/StoreValidator.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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 !',
|
||||
}
|
||||
}
|
||||
21
app/Validators/subscriber/UpdateValidator.ts
Normal file
21
app/Validators/subscriber/UpdateValidator.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
||||
|
||||
export default class UpdateValidator {
|
||||
constructor (private ctx: HttpContextContract) {
|
||||
}
|
||||
|
||||
public schema = schema.create({
|
||||
email: schema.string({ trim: true }, [
|
||||
rules.email(),
|
||||
rules.unique({table: 'subscribers', column: 'email'})
|
||||
]),
|
||||
name: schema.string.optional()
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user