1
0
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:
Jack Foltz 2018-07-28 16:53:02 -04:00
parent 740c153093
commit 2e268c83cb
Signed by: foltik
GPG Key ID: 303F88F996E95541

View File

@ -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();