-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(set-article-price): set article price
- update create article methods to set price - update update article controllers - update model and migration files - add validation methods for price input - add test for associated edge cases [Delivers #159568537]
- Loading branch information
1 parent
e875c01
commit 3f324d1
Showing
10 changed files
with
1,997 additions
and
1,859 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,4 +1,5 @@ | ||
import { } from 'dotenv/config'; | ||
|
||
module.exports = { | ||
development: { | ||
username: process.env.DB_USER, | ||
|
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
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,32 @@ | ||
const validatePrice = (req, res, next) => { | ||
if (req.body.article.price && typeof req.body.article.price !== 'number') { | ||
|
||
return res.status(400).json({ | ||
errors: { | ||
body: [ | ||
'Article price must be in figure' | ||
] | ||
} | ||
}); | ||
} | ||
if (req.body.article.isPaidFor && !req.body.article.price) { | ||
return res.status(400).json({ | ||
errors: { | ||
body: [ | ||
'Article is to be paid for, but price is not set' | ||
] | ||
} | ||
}); | ||
} | ||
if (req.body.article.price <= 0.28 || req.body.article.price >= 5.53) { | ||
return res.status(400).json({ | ||
errors: { | ||
body: [ | ||
'Price can only be between $0.28 to $5.53' | ||
] | ||
} | ||
}); | ||
} | ||
next(); | ||
}; | ||
export default validatePrice; |
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
Oops, something went wrong.