v1.7.4/release
- create party tests
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
const admin = require('firebase-admin');
|
||||
|
||||
const partyNameHasInvalidChar = (partyName) =>
|
||||
/\\/gi.test(partyName) || /\//gi.test(partyName) || /\./gi.test(partyName);
|
||||
|
||||
const isValidPin = (pin) => /^.*[0-9].{2}$/.test(pin);
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const bodydata = JSON.parse(req.body);
|
||||
console.log('Requested Create - UID - ', bodydata.uid);
|
||||
if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' });
|
||||
if (!bodydata.partyName) res.status(400).send({ message: 'Missing party name' });
|
||||
if (!bodydata.partyPin) res.status(400).send({ message: 'Missing party pin' });
|
||||
if (partyNameHasInvalidChar(bodydata.partyName)) {
|
||||
res.status(400).send({ message: 'Party name can not have "\\" or "/" or "."' });
|
||||
}
|
||||
if (!isValidPin(bodydata.partyPin)) {
|
||||
res
|
||||
.status(400)
|
||||
.send({ message: 'Party pin can only have digits and must be atleast 3 digits' });
|
||||
}
|
||||
const roomNameTaken = await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
|
||||
Reference in New Issue
Block a user