mirror of
https://github.com/skidoodle/erettsegi-browser.git
synced 2025-02-15 05:39:15 +01:00
Improve subject validation
This commit is contained in:
parent
1f142b2f1c
commit
752d100505
1 changed files with 5 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { subjects } from '@/utils/subjects'
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { ev, szint, vizsgatargy, idoszak } = req.query
|
||||
|
@ -16,21 +17,13 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||
.json({ error: `Hiányzó paraméterek: ${missingParams.join(', ')}` })
|
||||
}
|
||||
|
||||
if (ev! <= '2005') {
|
||||
if (ev! <= '2012') {
|
||||
return res.status(400).json({ error: 'Érvénytelen év' })
|
||||
}
|
||||
|
||||
switch (vizsgatargy) {
|
||||
case 'magyir':
|
||||
case 'mat':
|
||||
case 'tort':
|
||||
case 'angol':
|
||||
case 'nemet':
|
||||
case 'inf':
|
||||
case 'infoism':
|
||||
break
|
||||
default:
|
||||
return res.status(400).json({ error: 'Érvénytelen vizsgatárgy' })
|
||||
const validSubjects = subjects.map((subject) => subject.value)
|
||||
if (!vizsgatargy || !validSubjects.includes(vizsgatargy as string)) {
|
||||
return res.status(400).json({ error: 'Érvénytelen vizsgatárgy' })
|
||||
}
|
||||
|
||||
let honap
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue