Validate that the rating of a review only contains 1 decimal place
This commit is contained in:
parent
ecfe99912b
commit
d865b56c63
|
@ -2,7 +2,11 @@ import { object, string, number, InferType } from "yup";
|
|||
|
||||
export const reviewSchema = object({
|
||||
username: string().required(),
|
||||
rating: number().positive().max(5).required(),
|
||||
rating: number().positive().max(5).test(
|
||||
"maxDigitsAfterDecimal",
|
||||
"Rating must have at most 1 decimal place",
|
||||
number => Number.isInteger(number! * 10)
|
||||
).required(),
|
||||
content: string(),
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue