mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
Init
This commit is contained in:
21
src/schemas/auth.schema.ts
Normal file
21
src/schemas/auth.schema.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const loginSchema = z.object({
|
||||
email: z.email("Invalid email address"),
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
});
|
||||
|
||||
export const registerSchema = z
|
||||
.object({
|
||||
name: z.string().min(2, "Name must be at least 2 characters"),
|
||||
email: z.email("Invalid email address"),
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
confirmPassword: z.string(),
|
||||
})
|
||||
.refine((data) => data.password === data.confirmPassword, {
|
||||
message: "Passwords do not match",
|
||||
path: ["confirmPassword"],
|
||||
});
|
||||
|
||||
export type LoginInput = z.infer<typeof loginSchema>;
|
||||
export type RegisterInput = z.infer<typeof registerSchema>;
|
||||
21
src/schemas/filament.schema.ts
Normal file
21
src/schemas/filament.schema.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { z } from "zod/v4";
|
||||
import { MATERIALS } from "@/lib/constants";
|
||||
|
||||
export const filamentSchema = z.object({
|
||||
name: z.string().min(1, "Name is required").max(128),
|
||||
brand: z.string().min(1, "Brand is required").max(64),
|
||||
material: z.enum(MATERIALS),
|
||||
color: z.string().min(1, "Color name is required").max(64),
|
||||
colorHex: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color"),
|
||||
diameter: z.coerce.number().positive().default(1.75),
|
||||
spoolWeight: z.coerce.number().positive("Spool weight must be positive"),
|
||||
usedWeight: z.coerce.number().min(0).default(0),
|
||||
emptySpoolWeight: z.coerce.number().min(0).default(0),
|
||||
vendorId: z.string().optional().or(z.literal("")),
|
||||
locationId: z.string().optional().or(z.literal("")),
|
||||
purchaseDate: z.string().optional().or(z.literal("")),
|
||||
cost: z.coerce.number().min(0).optional(),
|
||||
notes: z.string().max(1024).optional(),
|
||||
});
|
||||
|
||||
export type FilamentInput = z.output<typeof filamentSchema>;
|
||||
8
src/schemas/location.schema.ts
Normal file
8
src/schemas/location.schema.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const locationSchema = z.object({
|
||||
name: z.string().min(1, "Name is required").max(64),
|
||||
description: z.string().max(256).optional(),
|
||||
});
|
||||
|
||||
export type LocationInput = z.infer<typeof locationSchema>;
|
||||
20
src/schemas/paint.schema.ts
Normal file
20
src/schemas/paint.schema.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod/v4";
|
||||
import { PAINT_FINISHES } from "@/lib/constants";
|
||||
|
||||
export const paintSchema = z.object({
|
||||
name: z.string().min(1, "Name is required").max(128),
|
||||
brand: z.string().min(1, "Brand is required").max(64),
|
||||
line: z.string().max(64).optional().or(z.literal("")),
|
||||
color: z.string().min(1, "Color name is required").max(64),
|
||||
colorHex: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color"),
|
||||
finish: z.enum(PAINT_FINISHES),
|
||||
volumeML: z.coerce.number().positive("Volume must be positive"),
|
||||
usedML: z.coerce.number().min(0).default(0),
|
||||
vendorId: z.string().optional().or(z.literal("")),
|
||||
locationId: z.string().optional().or(z.literal("")),
|
||||
purchaseDate: z.string().optional().or(z.literal("")),
|
||||
cost: z.coerce.number().min(0).optional(),
|
||||
notes: z.string().max(1024).optional(),
|
||||
});
|
||||
|
||||
export type PaintInput = z.output<typeof paintSchema>;
|
||||
19
src/schemas/resin.schema.ts
Normal file
19
src/schemas/resin.schema.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { z } from "zod/v4";
|
||||
import { RESIN_TYPES } from "@/lib/constants";
|
||||
|
||||
export const resinSchema = z.object({
|
||||
name: z.string().min(1, "Name is required").max(128),
|
||||
brand: z.string().min(1, "Brand is required").max(64),
|
||||
resinType: z.enum(RESIN_TYPES),
|
||||
color: z.string().min(1, "Color name is required").max(64),
|
||||
colorHex: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Invalid hex color"),
|
||||
bottleSize: z.coerce.number().positive("Bottle size must be positive"),
|
||||
usedML: z.coerce.number().min(0).default(0),
|
||||
vendorId: z.string().optional().or(z.literal("")),
|
||||
locationId: z.string().optional().or(z.literal("")),
|
||||
purchaseDate: z.string().optional().or(z.literal("")),
|
||||
cost: z.coerce.number().min(0).optional(),
|
||||
notes: z.string().max(1024).optional(),
|
||||
});
|
||||
|
||||
export type ResinInput = z.output<typeof resinSchema>;
|
||||
11
src/schemas/settings.schema.ts
Normal file
11
src/schemas/settings.schema.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { z } from "zod/v4";
|
||||
import { CURRENCIES, UNITS } from "@/lib/constants";
|
||||
|
||||
export const settingsSchema = z.object({
|
||||
lowStockThreshold: z.coerce.number().min(0).max(100).default(10),
|
||||
currency: z.enum(CURRENCIES).default("USD"),
|
||||
theme: z.enum(["dark", "light", "system"]).default("dark"),
|
||||
units: z.enum(UNITS).default("metric"),
|
||||
});
|
||||
|
||||
export type SettingsInput = z.output<typeof settingsSchema>;
|
||||
8
src/schemas/usage-log.schema.ts
Normal file
8
src/schemas/usage-log.schema.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const usageLogSchema = z.object({
|
||||
amount: z.coerce.number().positive("Amount must be positive"),
|
||||
notes: z.string().max(512).optional(),
|
||||
});
|
||||
|
||||
export type UsageLogInput = z.output<typeof usageLogSchema>;
|
||||
9
src/schemas/vendor.schema.ts
Normal file
9
src/schemas/vendor.schema.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
export const vendorSchema = z.object({
|
||||
name: z.string().min(1, "Name is required").max(64),
|
||||
website: z.string().url().optional().or(z.literal("")),
|
||||
notes: z.string().max(1024).optional(),
|
||||
});
|
||||
|
||||
export type VendorInput = z.infer<typeof vendorSchema>;
|
||||
Reference in New Issue
Block a user