simple-review-server/src/types.ts

14 lines
388 B
TypeScript
Raw Normal View History

2024-08-16 15:04:52 -04:00
import { object, string, number, InferType } from "yup";
export const reviewSchema = object({
username: string().required(),
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>;