mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-16 09:41:31 +10:00
refactor(v4.0.0-alpha): beginning of a new era
This commit is contained in:
31
libs/dto/src/user/user.ts
Normal file
31
libs/dto/src/user/user.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
|
||||
export const usernameSchema = z
|
||||
.string()
|
||||
.min(3)
|
||||
.max(255)
|
||||
.regex(/^[a-z0-9._-]+$/, {
|
||||
message:
|
||||
"Usernames can only contain lowercase letters, numbers, periods, hyphens, and underscores.",
|
||||
});
|
||||
|
||||
export const userSchema = z.object({
|
||||
id: idSchema,
|
||||
name: z.string().min(3).max(255),
|
||||
picture: z.literal("").or(z.null()).or(z.string().url()),
|
||||
username: usernameSchema,
|
||||
email: z.string().email(),
|
||||
language: z.string().default("en"),
|
||||
emailVerified: z.boolean().default(false),
|
||||
twoFactorEnabled: z.boolean().default(false),
|
||||
provider: z.enum(["email", "github", "google"]).default("email"),
|
||||
createdAt: z.date().or(z.dateString()),
|
||||
updatedAt: z.date().or(z.dateString()),
|
||||
});
|
||||
|
||||
export class UserDto extends createZodDto(userSchema) {}
|
||||
|
||||
export type UserWithSecrets = Prisma.UserGetPayload<{ include: { secrets: true } }>;
|
||||
Reference in New Issue
Block a user