From 42b8b0840ad59c79216a5b1afdd5451fef635881 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange Date: Mon, 3 Jul 2023 00:30:27 -0500 Subject: [PATCH] whups --- src/pages/api/troll/[user]/[troll]/index.ts | 5 ++--- src/types/client/troll.ts | 14 ++++++++++---- tsconfig.json | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pages/api/troll/[user]/[troll]/index.ts b/src/pages/api/troll/[user]/[troll]/index.ts index 9a92fe4..ae1d3c0 100644 --- a/src/pages/api/troll/[user]/[troll]/index.ts +++ b/src/pages/api/troll/[user]/[troll]/index.ts @@ -10,8 +10,7 @@ import { } from "@/lib/trollcall/perms"; import { changeTroll, getSingleTroll } from "@/lib/trollcall/troll"; import { getSingleUser } from "@/lib/trollcall/user"; -import { SubmitTroll } from "@/types/client/troll"; -import { PartialUserSchema } from "@/types/client/user"; +import { PartialTrollSchema, SubmitTroll } from "@/types/client/troll"; import { Router } from "express"; import { NextApiRequest, NextApiResponse } from "next"; @@ -37,7 +36,7 @@ export default async function handler( } else if (method === "PUT") { let validatedTroll: Partial; try { - validatedTroll = (await PartialUserSchema.validate(body, { + validatedTroll = (await PartialTrollSchema.validate(body, { stripUnknown: true })) as Partial; } catch (err) { diff --git a/src/types/client/troll.ts b/src/types/client/troll.ts index b130534..8693cea 100644 --- a/src/types/client/troll.ts +++ b/src/types/client/troll.ts @@ -109,6 +109,7 @@ export const SubmitTrollSchema = yup return v === "" ? null : v; }) .oneOf(TrueSignKeys), // "Keelez Bunbat" + prioritizeTrueSign: yup.boolean().default(false), class: yup.string().required().oneOf(ClassKeys), // Trollian @@ -127,10 +128,11 @@ export const SubmitTrollSchema = yup species: yup .string() .notRequired() - .matches(/^([A-z-]+)|()$/, "Letters only"), // "Troll-*" if defined. Otherwise, just "Troll". + .matches(/^([A-z-]+)|()$/, "Letters only") + .max(50), // "Troll-*" if defined. Otherwise, just "Troll". height: yup.number().required().positive(), // Inches age: yup.number().required().positive(), // Sweeps - image: yup.string().required().url(), + images: yup.array().of(yup.string().required().url()).required(), // Meta stuff policies: yup .object({ @@ -221,6 +223,7 @@ export const PartialTrollSchema = yup return v === "" ? null : v; }) .oneOf(TrueSignKeys), // "Keelez Bunbat" + prioritizeTrueSign: yup.boolean(), class: yup.string().oneOf(ClassKeys), // Trollian @@ -239,10 +242,13 @@ export const PartialTrollSchema = yup // Handled! :D // Physical stuff - species: yup.string().matches(/^([A-z-]+)|()$/, "Letters only"), // "Troll-*" if defined. Otherwise, just "Troll". + species: yup + .string() + .matches(/^([A-z-]+)|()$/, "Letters only") + .max(50), // "Troll-*" if defined. Otherwise, just "Troll". height: yup.number().positive(), // Inches age: yup.number().positive(), // Sweeps - image: yup.string().url(), + images: yup.array().of(yup.string().url()), // Meta stuff policies: yup.object({ fanart: PolicySchema, diff --git a/tsconfig.json b/tsconfig.json index c12c62a..f082d2e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, + "noErrorTruncation": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true,