import { object, string, number, InferType } from "yup"; export const typeJson = {"Content-Type": "application/json"}; export const userReviewSchema = object({ username: string().min(2).max(30).required(), rating: number() .positive() .max(5) .test( "maxDigitsAfterDecimal", "Rating can only have at most one integer at half intervals (.0 or .5)", (number) => (number! * 10) % 5 === 0, ) .required(), title: string().max(50).notRequired(), content: string().max(2000).notRequired(), }); export const serverReviewSchema = userReviewSchema.shape({ id: string().length(6).required() }) export type UserSideReview = InferType; export type ServerSideReview = InferType;