2024-08-16 15:04:52 -04:00
|
|
|
import { object, string, number, InferType } from "yup";
|
|
|
|
|
|
|
|
export const reviewSchema = object({
|
|
|
|
username: string().required(),
|
2024-08-18 17:59:11 -04:00
|
|
|
rating: number().positive().max(5).test(
|
|
|
|
"maxDigitsAfterDecimal",
|
|
|
|
"Rating must have at most 1 decimal place",
|
|
|
|
number => Number.isInteger(number! * 10)
|
|
|
|
).required(),
|
2024-08-16 15:04:52 -04:00
|
|
|
content: string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export type Review = InferType<typeof reviewSchema>;
|