Updated validtion for unit and weight

This commit is contained in:
Andrew Scott 2022-06-04 23:22:47 -04:00
parent e91b3b3aac
commit 95bb1aa7ca
Signed by: a
GPG key ID: 3EB62D0BBB8DB381

View file

@ -55,19 +55,18 @@ app.post(
let isValid; let isValid;
if (req.body.name === "" || typeof req.body.name !== "string") { if (req.body.name === "" || typeof req.body.name !== "string") {
isValid = false; isValid = false;
//console.log("name"); } else if (!Number.isInteger(parseInt(req.body.reps))) {
isValid = false;
} else if (req.body.reps < 1) { } else if (req.body.reps < 1) {
isValid = false; isValid = false;
//console.log("reps"); } else if (!Number.isInteger(parseInt(req.body.weight))) {
isValid = false;
} else if (req.body.weight < 1) { } else if (req.body.weight < 1) {
isValid = false; isValid = false;
//console.log("weight");
} else if (req.body.unit !== "lbs" && req.body.unit !== "kgs") { } else if (req.body.unit !== "lbs" && req.body.unit !== "kgs") {
isValid = false; isValid = false;
//console.log("unit");
} else if (!isDateValid(req.body.date)) { } else if (!isDateValid(req.body.date)) {
isValid = false; isValid = false;
//console.log("date");
} else { } else {
isValid = true; isValid = true;
} }
@ -96,8 +95,12 @@ app.put(
let resultVal; let resultVal;
if (req.body.name === "" || typeof req.body.name !== "string") { if (req.body.name === "" || typeof req.body.name !== "string") {
isValid = false; isValid = false;
} else if (!Number.isInteger(parseInt(req.body.reps))) {
isValid = false;
} else if (req.body.reps < 1) { } else if (req.body.reps < 1) {
isValid = false; isValid = false;
} else if (!Number.isInteger(parseInt(req.body.weight))) {
isValid = false;
} else if (req.body.weight < 1) { } else if (req.body.weight < 1) {
isValid = false; isValid = false;
} else if (req.body.unit !== "lbs" && req.body.unit !== "kgs") { } else if (req.body.unit !== "lbs" && req.body.unit !== "kgs") {