mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 16:22:59 +10:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { idSchema } from "@reactive-resume/schema";
|
|
import { createZodDto } from "nestjs-zod/dto";
|
|
import { z } from "nestjs-zod/z";
|
|
|
|
import { secretsSchema } from "../secrets";
|
|
|
|
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(1).max(255),
|
|
picture: z.literal("").or(z.null()).or(z.string().url()),
|
|
username: usernameSchema,
|
|
email: z.string().email(),
|
|
locale: z.string().default("en-US"),
|
|
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 const userWithSecretsSchema = userSchema.merge(z.object({ secrets: secretsSchema }));
|
|
|
|
export class UserWithSecrets extends createZodDto(userWithSecretsSchema) {}
|