Add 'title' to Review and add length limits to all string values
This commit is contained in:
parent
6041aea8ed
commit
8d6572c631
|
@ -1,13 +1,14 @@
|
||||||
import { object, string, number, InferType } from "yup";
|
import { object, string, number, InferType } from "yup";
|
||||||
|
|
||||||
export const reviewSchema = object({
|
export const reviewSchema = object({
|
||||||
username: string().required(),
|
username: string().strict(true).max(30).required(),
|
||||||
rating: number().positive().max(5).test(
|
rating: number().positive().max(5).test(
|
||||||
"maxDigitsAfterDecimal",
|
"maxDigitsAfterDecimal",
|
||||||
"Rating must have at most 1 decimal place",
|
"Rating can only have at most one integer at half intervals (.0 or .5)",
|
||||||
number => Number.isInteger(number! * 10)
|
number => { !((number! * 10) % 5) }
|
||||||
).required(),
|
).required(),
|
||||||
content: string(),
|
title: string().strict(true).max(50).required(),
|
||||||
|
content: string().strict(true).max(2000).notRequired(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type Review = InferType<typeof reviewSchema>;
|
export type Review = InferType<typeof reviewSchema>;
|
||||||
|
|
Loading…
Reference in a new issue