mirror of
https://github.com/ArthurDanjou/artdanj-shortener.git
synced 2026-01-30 17:28:46 +01:00
rework and update deps
This commit is contained in:
22
app/Validators/StoreValidator.ts
Normal file
22
app/Validators/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({
|
||||
code: schema.string({}, [
|
||||
rules.unique({table: 'links', column: 'code' }),
|
||||
rules.maxLength(10)
|
||||
]),
|
||||
target: schema.string({}),
|
||||
})
|
||||
|
||||
public cacheKey = this.ctx.routeKey
|
||||
|
||||
public messages = {
|
||||
'code.unique': 'The code already exist !',
|
||||
'code.maxLength': 'The code is too long ! (max 10 caracteres)'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user