54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import vine from '@vinejs/vine'
|
|
|
|
export const requestLoginValidator = vine.compile(
|
|
vine.object({
|
|
email: vine
|
|
.string()
|
|
.email({
|
|
host_whitelist: ['bginette.fr'],
|
|
})
|
|
.normalizeEmail({
|
|
all_lowercase: true,
|
|
}).trim(),
|
|
})
|
|
)
|
|
|
|
export const verifyCodeValidator = vine.compile(
|
|
vine.object({
|
|
code: vine.string().minLength(6).maxLength(6),
|
|
})
|
|
)
|
|
|
|
function toTitleCase(value: string) {
|
|
return value.replace(/\w\S*/g, (txt) => {
|
|
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()
|
|
})
|
|
}
|
|
|
|
export const registerValidator = vine.compile(
|
|
vine.object({
|
|
firstName: vine.string().minLength(2).maxLength(50).trim().transform(toTitleCase),
|
|
lastName: vine.string().minLength(2).maxLength(50).trim().toUpperCase(),
|
|
className: vine.string().minLength(2).maxLength(50),
|
|
token: vine.string(),
|
|
})
|
|
)
|
|
|
|
// TODO: Magic link login
|
|
// export const magicLinkValidator = vine.compile(
|
|
// vine.object({
|
|
// token: vine.string(),
|
|
// })
|
|
// )
|
|
|
|
// export const listenValidator = vine.compile(
|
|
// vine.object({
|
|
// token: vine.string().uuid(),
|
|
// })
|
|
// )
|
|
|
|
// export const exchangeTokenValidator = vine.compile(
|
|
// vine.object({
|
|
// token: vine.string().uuid(),
|
|
// })
|
|
// )
|