mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
21 lines
672 B
JavaScript
21 lines
672 B
JavaScript
import { check } from 'express-validator'
|
|
import { checkQuestId } from './questValidator.js'
|
|
import { noError } from '../../middleware/validator.js'
|
|
|
|
const checkSessionStatus = () =>
|
|
check('status')
|
|
.isString()
|
|
.custom((value) => ['active', 'inactive', 'finished'].includes(value))
|
|
|
|
export const checkSessionId = () =>
|
|
check('sessionId').notEmpty().isString().isMongoId()
|
|
|
|
export const sessionListValidator = [
|
|
checkQuestId(),
|
|
checkSessionStatus(),
|
|
noError,
|
|
]
|
|
export const sessionDetailValidator = [checkSessionId(), noError]
|
|
export const createSessionValidator = [checkQuestId(), noError]
|
|
export const activeSessionValidator = [checkQuestId(), noError]
|