-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added barter payment initiator method with redis queue
- Loading branch information
1 parent
1c86135
commit 92e5937
Showing
6 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
node_modules | ||
node_modules | ||
*.git | ||
dist | ||
build | ||
package-lock.json | ||
.npm | ||
*.vscode | ||
*.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,10 @@ | |
|
||
|
||
#ignore specific file | ||
src/utils/constants.js | ||
src/utils/constants.js | ||
|
||
*.vscode | ||
|
||
build | ||
dist | ||
.npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const validator = require("validator"); | ||
const { isMongoId, isFloat, isEmpty } = validator; | ||
|
||
function validateBarterPayInput(creditorID, groupID, amount, barterType) { | ||
const errors = new Map(); | ||
|
||
// Validate creditor ID | ||
if (!isMongoId(creditorID)) { | ||
errors.set("creditorID", "Invalid creditor ID"); | ||
} | ||
// Validate Debtor ID | ||
if (!isMongoId(debtorId)) { | ||
errors.set("debtorID", "Invalid debtor ID"); | ||
} | ||
|
||
// Validate group ID | ||
if (!isMongoId(groupId)) { | ||
errors.set("groupId", "Invalid group ID"); | ||
} | ||
|
||
// Validate amount | ||
if (!isFloat(amount.toString(), { min: 0 })) { | ||
errors.set("amount", "Amount must be a positive number."); | ||
} | ||
|
||
// Validate barterType | ||
if (isEmpty(barterType)) { | ||
errors.set("barterType", "Barter type is required."); | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
module.exports = validateBarterPayInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters