blob: b395dbf82cb06e18198f5ad59d22f9b3f06a554b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
* Accepts a ZBLOCK!
*
* Checks:
* 1. Exists,
* 2. Length is 46 bytes,
* 3. Matches regular expression /Qm[A-Za-z0-9]{44}/
*
* Returns:
* - error on failure
* - on success the string is processed for further
* validation to the function getvalidity()
*
*/
const getvalidity = require('../../validators/ZblockValidator')
module.exports = (req, res) => {
console.log(req);
console.log("okay we got called");
if ( (req.body.zblock) && req.body.zblock.length === 46 ){
regex= /Qm[A-Za-z0-9]{44}/;
if (regex.test(req.body.zblock)){
getvalidity(req.body.zblock,res);
} else {
res.send({error:"Invalid data"});
}
} else {
res.send({error:"Invalid data"});
}
}
|