mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-22 05:26:14 +08:00
checking with regex
This commit is contained in:
parent
c1fb60011e
commit
a926ad4d1f
1 changed files with 8 additions and 5 deletions
|
@ -105,6 +105,10 @@ router.post(
|
|||
asyncHandler(QuoteController.submitRating)
|
||||
);
|
||||
|
||||
const withCustomMessages = joi.string().messages({
|
||||
"string.pattern.base": "Invalid parameter format",
|
||||
});
|
||||
|
||||
router.post(
|
||||
"/report",
|
||||
validateConfiguration({
|
||||
|
@ -117,8 +121,8 @@ router.post(
|
|||
RateLimit.quoteReportSubmit,
|
||||
validateRequest({
|
||||
body: {
|
||||
quoteId: joi.string().required(),
|
||||
quoteLanguage: joi.string().regex(/^\w+$/).required(),
|
||||
quoteId: withCustomMessages.regex(/\d+/).required(),
|
||||
quoteLanguage: withCustomMessages.regex(/^\w+$/).required(),
|
||||
reason: joi
|
||||
.string()
|
||||
.valid(
|
||||
|
@ -128,13 +132,12 @@ router.post(
|
|||
"Incorrect source"
|
||||
)
|
||||
.required(),
|
||||
comment: joi
|
||||
.string()
|
||||
comment: withCustomMessages
|
||||
.allow("")
|
||||
.regex(/^([.]|[^/<>])+$/)
|
||||
.max(250)
|
||||
.required(),
|
||||
captcha: joi.string().required(),
|
||||
captcha: withCustomMessages.regex(/[\w-_]+/).required(),
|
||||
},
|
||||
}),
|
||||
checkUserPermissions({
|
||||
|
|
Loading…
Add table
Reference in a new issue