mirror of
https://github.com/ArthurDanjou/artdanj-shortener.git
synced 2026-01-21 20:23:19 +01:00
25 lines
610 B
TypeScript
Executable File
25 lines
610 B
TypeScript
Executable File
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
import {rules, schema} from '@ioc:Adonis/Core/Validator'
|
|
|
|
export default class LinkStoreValidator {
|
|
constructor (protected ctx: HttpContextContract) {}
|
|
|
|
public schema = schema.create({
|
|
code: schema.string({}, [
|
|
rules.unique({table: 'links', column: 'code' }),
|
|
rules.maxLength(10)
|
|
]),
|
|
target: schema.string({
|
|
trim: true
|
|
}),
|
|
type: schema.enum(
|
|
['TEMPORARY', 'PERMANENT'] as const
|
|
),
|
|
expire: schema.date.optional({
|
|
format: 'yyyy-MM-dd HH:mm:ss',
|
|
})
|
|
})
|
|
|
|
public messages = {}
|
|
}
|