This commit is contained in:
Kiss Dávid
2026-03-29 11:18:31 +02:00
parent 1ebb2e53a9
commit d55e085741
16 changed files with 4130 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
import vine from '@vinejs/vine'
export const createCategoryValidator = vine.compile(
vine.object({
name: vine.string().unique(async (db, value) => {
const match = await db.from('categories').select('id').where('name', value).first()
return !match
}),
nameHu: vine.string().optional(),
nameEn: vine.string().optional(),
slug: vine.string().unique(async (db, value) => {
const match = await db.from('categories').select('id').where('slug', value).first()
return !match
}),
})
)
export const updateCategoryValidator = vine.compile(
vine.object({
id: vine.number(),
name: vine
.string()
.unique(async (db, value, field) => {
const match = await db
.from('categories')
.select('id')
.where('name', value)
.whereNot('id', field.data.id)
.first()
return !match
})
.optional(),
nameHu: vine.string().optional(),
nameEn: vine.string().optional(),
slug: vine
.string()
.unique(async (db, value, field) => {
const match = await db
.from('categories')
.select('id')
.where('slug', value)
.whereNot('id', field.data.id)
.first()
return !match
})
.optional(),
})
)