mirror of
https://codeberg.org/andyscott/ExerciseTracker.git
synced 2024-12-21 11:43:10 -05:00
Updated validtion for unit and weight
This commit is contained in:
parent
e91b3b3aac
commit
95bb1aa7ca
1 changed files with 8 additions and 5 deletions
|
@ -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") {
|
||||||
|
|
Loading…
Reference in a new issue