initital commit

This commit is contained in:
2020-12-16 15:54:29 +01:00
commit a8ea2ef04a
75 changed files with 6664 additions and 0 deletions

View 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 !',
}
}

View 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 !',
}
}

View 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 !'
}
}

View 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 !',
}
}

View 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 !'
}
}

View 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 !',
}
}

View 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 !'
}
}

View 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 !',
}
}

View 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 !'
}
}