Initial commit: PC Builder AdonisJS project
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import vine from '@vinejs/vine'
|
||||
|
||||
export const loginValidator = vine.compile(
|
||||
vine.object({
|
||||
email: vine.string().email(),
|
||||
password: vine.string().minLength(8).maxLength(32),
|
||||
})
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
import vine from '@vinejs/vine'
|
||||
|
||||
export const registerValidator = vine.compile(
|
||||
vine.object({
|
||||
name: vine.string().minLength(3).maxLength(64),
|
||||
email: vine
|
||||
.string()
|
||||
.email()
|
||||
.unique(async (query, field) => {
|
||||
const user = await query.from('users').where('email', field).first()
|
||||
return !user
|
||||
}),
|
||||
password: vine.string().minLength(8).maxLength(32),
|
||||
})
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
import vine from '@vinejs/vine'
|
||||
|
||||
export const storeComponentValidator = vine.compile(
|
||||
vine.object({
|
||||
name: vine.string().trim().minLength(1),
|
||||
price: vine.number().decimal([0, 2]).min(0),
|
||||
typeId: vine.number().min(1),
|
||||
purchaseDate: vine.string().regex(/^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/),
|
||||
quantity: vine.number().min(1).withoutDecimals(),
|
||||
})
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
import vine from '@vinejs/vine'
|
||||
|
||||
const email = () => vine.string().email().maxLength(254)
|
||||
const password = () => vine.string().minLength(8).maxLength(32)
|
||||
|
||||
export const signupValidator = vine.create({
|
||||
fullName: vine.string().nullable(),
|
||||
email: email().unique({ table: 'users', column: 'email' }),
|
||||
password: password().confirmed({
|
||||
confirmationField: 'passwordConfirmation',
|
||||
}),
|
||||
})
|
||||
Reference in New Issue
Block a user