feat: submitting and validation

custom images of the mii are still not implemented
This commit is contained in:
trafficlunar 2025-04-05 14:45:22 +01:00
parent fb4d790b3d
commit 49c6206623
14 changed files with 514 additions and 63 deletions

2
src/lib/constants.ts Normal file
View file

@ -0,0 +1,2 @@
export const MII_DECRYPTION_KEY = new Uint8Array([0x59, 0xfc, 0x81, 0x7e, 0x64, 0x46, 0xea, 0x61, 0x90, 0x34, 0x7b, 0x20, 0xe9, 0xbd, 0xce, 0x52]);
export const MII_QR_SIZES = [0x70, 172, 324, 372];

22
src/lib/schemas.ts Normal file
View file

@ -0,0 +1,22 @@
import { z } from "zod";
export const nameSchema = z
.string()
.min(2, { message: "Name must be at least 2 characters long" })
.max(64, { message: "Name cannot be more than 64 characters long" })
.regex(/^[a-zA-Z0-9-_. ']+$/, {
message: "Name can only contain letters, numbers, dashes, underscores, apostrophes, and spaces.",
});
export const tagsSchema = z
.array(
z
.string()
.min(2, { message: "Tags must be at least 2 characters long" })
.max(64, { message: "Tags cannot be more than 20 characters long" })
.regex(/^[a-z0-9-_]+$/, {
message: "Tags can only contain lowercase letters, numbers, dashes, and underscores.",
})
)
.min(1, { message: "There must be at least 1 tag" })
.max(8, { message: "There cannot be more than 8 tags" });