whups
This commit is contained in:
parent
b3d1a530b6
commit
42b8b0840a
3 changed files with 13 additions and 7 deletions
|
@ -10,8 +10,7 @@ import {
|
||||||
} from "@/lib/trollcall/perms";
|
} from "@/lib/trollcall/perms";
|
||||||
import { changeTroll, getSingleTroll } from "@/lib/trollcall/troll";
|
import { changeTroll, getSingleTroll } from "@/lib/trollcall/troll";
|
||||||
import { getSingleUser } from "@/lib/trollcall/user";
|
import { getSingleUser } from "@/lib/trollcall/user";
|
||||||
import { SubmitTroll } from "@/types/client/troll";
|
import { PartialTrollSchema, SubmitTroll } from "@/types/client/troll";
|
||||||
import { PartialUserSchema } from "@/types/client/user";
|
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { NextApiRequest, NextApiResponse } from "next";
|
import { NextApiRequest, NextApiResponse } from "next";
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ export default async function handler(
|
||||||
} else if (method === "PUT") {
|
} else if (method === "PUT") {
|
||||||
let validatedTroll: Partial<SubmitTroll>;
|
let validatedTroll: Partial<SubmitTroll>;
|
||||||
try {
|
try {
|
||||||
validatedTroll = (await PartialUserSchema.validate(body, {
|
validatedTroll = (await PartialTrollSchema.validate(body, {
|
||||||
stripUnknown: true
|
stripUnknown: true
|
||||||
})) as Partial<SubmitTroll>;
|
})) as Partial<SubmitTroll>;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -109,6 +109,7 @@ export const SubmitTrollSchema = yup
|
||||||
return v === "" ? null : v;
|
return v === "" ? null : v;
|
||||||
})
|
})
|
||||||
.oneOf(TrueSignKeys), // "Keelez Bunbat"
|
.oneOf(TrueSignKeys), // "Keelez Bunbat"
|
||||||
|
prioritizeTrueSign: yup.boolean().default(false),
|
||||||
class: yup.string().required().oneOf(ClassKeys),
|
class: yup.string().required().oneOf(ClassKeys),
|
||||||
|
|
||||||
// Trollian
|
// Trollian
|
||||||
|
@ -127,10 +128,11 @@ export const SubmitTrollSchema = yup
|
||||||
species: yup
|
species: yup
|
||||||
.string()
|
.string()
|
||||||
.notRequired()
|
.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
|
height: yup.number().required().positive(), // Inches
|
||||||
age: yup.number().required().positive(), // Sweeps
|
age: yup.number().required().positive(), // Sweeps
|
||||||
image: yup.string().required().url(),
|
images: yup.array().of(yup.string().required().url()).required(),
|
||||||
// Meta stuff
|
// Meta stuff
|
||||||
policies: yup
|
policies: yup
|
||||||
.object({
|
.object({
|
||||||
|
@ -221,6 +223,7 @@ export const PartialTrollSchema = yup
|
||||||
return v === "" ? null : v;
|
return v === "" ? null : v;
|
||||||
})
|
})
|
||||||
.oneOf(TrueSignKeys), // "Keelez Bunbat"
|
.oneOf(TrueSignKeys), // "Keelez Bunbat"
|
||||||
|
prioritizeTrueSign: yup.boolean(),
|
||||||
class: yup.string().oneOf(ClassKeys),
|
class: yup.string().oneOf(ClassKeys),
|
||||||
|
|
||||||
// Trollian
|
// Trollian
|
||||||
|
@ -239,10 +242,13 @@ export const PartialTrollSchema = yup
|
||||||
// Handled! :D
|
// Handled! :D
|
||||||
|
|
||||||
// Physical stuff
|
// 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
|
height: yup.number().positive(), // Inches
|
||||||
age: yup.number().positive(), // Sweeps
|
age: yup.number().positive(), // Sweeps
|
||||||
image: yup.string().url(),
|
images: yup.array().of(yup.string().url()),
|
||||||
// Meta stuff
|
// Meta stuff
|
||||||
policies: yup.object({
|
policies: yup.object({
|
||||||
fanart: PolicySchema,
|
fanart: PolicySchema,
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
"noErrorTruncation": true,
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|
Loading…
Reference in a new issue