initial: standalone repo from monorepo split
This commit is contained in:
25
packages/shared/src/schemas/auth.ts
Normal file
25
packages/shared/src/schemas/auth.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const loginSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
password: z.string().min(8, 'Password must be at least 8 characters'),
|
||||
});
|
||||
|
||||
export const registerTenantSchema = z.object({
|
||||
tenantName: z.string().min(2, 'Tenant name must be at least 2 characters'),
|
||||
slug: z
|
||||
.string()
|
||||
.min(2)
|
||||
.max(50)
|
||||
.regex(
|
||||
/^[a-z0-9-]+$/,
|
||||
'Slug must contain only lowercase letters, numbers, and hyphens',
|
||||
),
|
||||
adminEmail: z.string().email('Invalid email address'),
|
||||
adminPassword: z.string().min(8, 'Password must be at least 8 characters'),
|
||||
adminFirstName: z.string().min(1, 'First name is required'),
|
||||
adminLastName: z.string().min(1, 'Last name is required'),
|
||||
});
|
||||
|
||||
export type LoginInput = z.infer<typeof loginSchema>;
|
||||
export type RegisterTenantInput = z.infer<typeof registerTenantSchema>;
|
||||
5
packages/shared/src/schemas/index.ts
Normal file
5
packages/shared/src/schemas/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export { loginSchema, registerTenantSchema } from './auth';
|
||||
export type { LoginInput, RegisterTenantInput } from './auth';
|
||||
|
||||
export { createUserSchema, updateUserSchema } from './user';
|
||||
export type { CreateUserInput, UpdateUserInput } from './user';
|
||||
27
packages/shared/src/schemas/user.ts
Normal file
27
packages/shared/src/schemas/user.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { z } from 'zod';
|
||||
import { Role } from '../constants/roles';
|
||||
|
||||
const roleEnum = z.enum([
|
||||
Role.SUPER_ADMIN,
|
||||
Role.TENANT_ADMIN,
|
||||
Role.MANAGER,
|
||||
Role.TECHNICIAN,
|
||||
Role.VIEWER,
|
||||
]);
|
||||
|
||||
export const createUserSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
password: z.string().min(8, 'Password must be at least 8 characters'),
|
||||
firstName: z.string().min(1, 'First name is required'),
|
||||
lastName: z.string().min(1, 'Last name is required'),
|
||||
roles: z.array(roleEnum).min(1, 'At least one role is required'),
|
||||
});
|
||||
|
||||
export const updateUserSchema = z.object({
|
||||
firstName: z.string().min(1).optional(),
|
||||
lastName: z.string().min(1).optional(),
|
||||
roles: z.array(roleEnum).min(1).optional(),
|
||||
});
|
||||
|
||||
export type CreateUserInput = z.infer<typeof createUserSchema>;
|
||||
export type UpdateUserInput = z.infer<typeof updateUserSchema>;
|
||||
Reference in New Issue
Block a user