mirror of
https://github.com/Foltik/Shimapan
synced 2025-02-05 09:15:16 -05:00
Only perform type and instance check if prop exists
This commit is contained in:
parent
740c153093
commit
2e268c83cb
@ -11,10 +11,10 @@ const verifyBody = expectedProps =>
|
|||||||
if (!expected.optional && !prop)
|
if (!expected.optional && !prop)
|
||||||
return res.status(400).json({message: expected.name + ' not specified.'});
|
return res.status(400).json({message: expected.name + ' not specified.'});
|
||||||
|
|
||||||
if (expected.type && typeof prop !== expected.type)
|
if (prop && expected.type && typeof prop !== expected.type)
|
||||||
return res.status(400).json({message: expected.name + ' malformed.'});
|
return res.status(400).json({message: expected.name + ' malformed.'});
|
||||||
|
|
||||||
if (expected.instance && !(prop instanceof expected.instance))
|
if (prop && expected.instance && !(prop instanceof expected.instance))
|
||||||
return res.status(400).json({message: expected.name + ' malformed.'});
|
return res.status(400).json({message: expected.name + ' malformed.'});
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
Loading…
Reference in New Issue
Block a user