forked from Split-Naira/SplitNaira
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.schemas.ts
More file actions
31 lines (27 loc) · 951 Bytes
/
Copy pathuser.schemas.ts
File metadata and controls
31 lines (27 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { z } from "zod";
// Stellar address validator
export const stellarAddressSchema = z
.string()
.min(1, "wallet address is required")
.regex(/^G[A-Z2-7]{55}$/, {
message: "Must be a valid Stellar account ID (G…)",
});
// User registration schema
export const userRegistrationSchema = z.object({
walletAddress: stellarAddressSchema,
email: z.string().email("Invalid email format").optional(),
alias: z.string().min(1, "Alias is required").max(64, "Alias must be at most 64 characters").optional(),
});
// User response schema
export const userResponseSchema = z.object({
id: z.string().uuid(),
walletAddress: z.string(),
email: z.string().optional(),
alias: z.string().optional(),
role: z.string(),
isActive: z.boolean(),
createdAt: z.string(),
updatedAt: z.string(),
});
export type UserRegistration = z.infer<typeof userRegistrationSchema>;
export type UserResponse = z.infer<typeof userResponseSchema>;