mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-14 20:19:26 +01:00
initital commit
This commit is contained in:
26
app/Validators/AuthValidator.ts
Normal file
26
app/Validators/AuthValidator.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
||||
|
||||
export default class AuthValidator {
|
||||
constructor (private ctx: HttpContextContract) {
|
||||
}
|
||||
|
||||
public schema = schema.create({
|
||||
email: schema.string({ trim: true }, [
|
||||
rules.email(),
|
||||
rules.required()
|
||||
]),
|
||||
password: schema.string({ trim: true }, [
|
||||
rules.required()
|
||||
]),
|
||||
remember_me: schema.boolean()
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
'email.email': 'L\'adresse mail n\'est pas valide !',
|
||||
'email.required': 'Veuillez renseigner une adresse mail !',
|
||||
'password.required': 'Veuillez renseigner un mot de passe !',
|
||||
}
|
||||
}
|
||||
19
app/Validators/locations/StoreValidator.ts
Normal file
19
app/Validators/locations/StoreValidator.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
||||
|
||||
export default class StoreValidator {
|
||||
constructor (private ctx: HttpContextContract) {
|
||||
}
|
||||
|
||||
public schema = schema.create({
|
||||
place: schema.string(),
|
||||
since: schema.date(),
|
||||
left: schema.string(),
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !',
|
||||
}
|
||||
}
|
||||
19
app/Validators/locations/UpdateValidator.ts
Normal file
19
app/Validators/locations/UpdateValidator.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import {schema} from '@ioc:Adonis/Core/Validator'
|
||||
|
||||
export default class UpdateValidator {
|
||||
constructor (private ctx: HttpContextContract) {
|
||||
}
|
||||
|
||||
public schema = schema.create({
|
||||
place: schema.string.optional(),
|
||||
since: schema.date.optional(),
|
||||
left: schema.string.optional(),
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !'
|
||||
}
|
||||
}
|
||||
25
app/Validators/posts/StoreValidator.ts
Normal file
25
app/Validators/posts/StoreValidator.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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({
|
||||
title: schema.string(),
|
||||
content: schema.string(),
|
||||
description: schema.string(),
|
||||
readingTime: schema.number(),
|
||||
coverId: schema.number([rules.exists({ table: 'files', column: 'id' })]),
|
||||
tags: schema.array().members(
|
||||
schema.number()
|
||||
),
|
||||
lightBackGround: schema.boolean()
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !',
|
||||
}
|
||||
}
|
||||
25
app/Validators/posts/UpdateValidator.ts
Normal file
25
app/Validators/posts/UpdateValidator.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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({
|
||||
title: schema.string.optional(),
|
||||
content: schema.string.optional(),
|
||||
description: schema.string.optional(),
|
||||
readingTime: schema.number.optional(),
|
||||
coverId: schema.number.optional([rules.exists({ table: 'files', column: 'id' })]),
|
||||
tags: schema.array.optional().members(
|
||||
schema.number()
|
||||
),
|
||||
lightBackGround: schema.boolean.optional()
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !'
|
||||
}
|
||||
}
|
||||
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 !'
|
||||
}
|
||||
}
|
||||
22
app/Validators/users/StoreValidator.ts
Normal file
22
app/Validators/users/StoreValidator.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 StoreValidator {
|
||||
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 !',
|
||||
}
|
||||
}
|
||||
23
app/Validators/users/UpdateValidator.ts
Normal file
23
app/Validators/users/UpdateValidator.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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.optional({ trim: true, escape: true }, [rules.email()]),
|
||||
password: schema.string.optional({ trim: true, escape: true }, [rules.confirmed()]),
|
||||
is_confirmed: schema.boolean.optional(),
|
||||
confirmation_token: schema.string.optional({ trim: true, escape: true }),
|
||||
remember_me: schema.string.optional({ trim: true, escape: true }),
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
required: 'Le champ {{field}} doit être valide !',
|
||||
'email.email': 'L\'adresse mail doit être valide !',
|
||||
'password.confirmation': 'Les mots de passe ne correspondent pas !'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user