Add 'title' to Review and add length limits to all string values

This commit is contained in:
powermaker450 2024-08-18 23:30:53 -04:00
parent 6041aea8ed
commit 8d6572c631

View file

@ -1,13 +1,14 @@
import { object, string, number, InferType } from "yup";
export const reviewSchema = object({
username: string().required(),
username: string().strict(true).max(30).required(),
rating: number().positive().max(5).test(
"maxDigitsAfterDecimal",
"Rating must have at most 1 decimal place",
number => Number.isInteger(number! * 10)
"Rating can only have at most one integer at half intervals (.0 or .5)",
number => { !((number! * 10) % 5) }
).required(),
content: string(),
title: string().strict(true).max(50).required(),
content: string().strict(true).max(2000).notRequired(),
});
export type Review = InferType<typeof reviewSchema>;