import { object, string, number, InferType } from "yup"; import { Request } from "express"; const 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(); export const typeJson = { "Access-Control-Allow-Origin": "*", "Content-Type": "application/json" }; export const userReviewSchema = object({ username: string().min(2).max(30).required(), rating: rating, title: string().max(50).notRequired(), content: string().max(2000).notRequired(), }); export const serverReviewSchema = userReviewSchema.shape({ id: string().length(6).required(), timestamp: string().required(), }); export type UserSideReview = InferType; export type ServerSideReview = InferType; export type userRating = InferType; export interface IdRequest extends Request { params: { id: string; }; }