mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-10 15:48:27 -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)
|
||||
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.'});
|
||||
|
||||
if (expected.instance && !(prop instanceof expected.instance))
|
||||
if (prop && expected.instance && !(prop instanceof expected.instance))
|
||||
return res.status(400).json({message: expected.name + ' malformed.'});
|
||||
}
|
||||
next();
|
||||
|
Loading…
Reference in New Issue
Block a user