Skip to content

Commit c8cccd8

Browse files
committed
fixed the comments by @DashDeipayan in all 3 validator function
1 parent ff0b91f commit c8cccd8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

middlewares/validators/progresses.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ const validateCreateProgressRecords = async (req, res, next) => {
5050
const validateGetProgressRecordsQuery = async (req, res, next) => {
5151
const schema = joi
5252
.object({
53-
type: joi.string().valid("user", "task").optional().messages({
54-
"any.only": "Type field is restricted to either 'user' or 'task'.",
55-
}),
53+
type: joi
54+
.string()
55+
.valid(...VALID_PROGRESS_TYPES)
56+
.optional()
57+
.messages({
58+
"any.only": "Type field is restricted to either 'user' or 'task'.",
59+
}),
5660
userId: joi.string().optional().allow("").messages({
5761
"string.base": "userId must be a string",
5862
}),
@@ -101,9 +105,13 @@ const validateGetRangeProgressRecordsParams = async (req, res, next) => {
101105

102106
const validateGetDayProgressParams = async (req, res, next) => {
103107
const schema = joi.object({
104-
type: joi.string().valid("user", "task").required().messages({
105-
"any.only": "Type field is restricted to either 'user' or 'task'.",
106-
}),
108+
type: joi
109+
.string()
110+
.valid(...VALID_PROGRESS_TYPES)
111+
.required()
112+
.messages({
113+
"any.only": "Type field is restricted to either 'user' or 'task'.",
114+
}),
107115
typeId: joi.string().required(),
108116
date: joi.date().iso().required(),
109117
});

0 commit comments

Comments
 (0)