Skip to content

Commit

Permalink
Update profile.js
Browse files Browse the repository at this point in the history
Prevent user from submitting invalid date ranges for education and experience (currently you can submit a FROM date that is after the TO date which is chronologically invalid).
  • Loading branch information
NguyenDa18 committed Feb 18, 2020
1 parent f64c3bd commit 680c808
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions routes/api/profile.js
Expand Up @@ -171,9 +171,10 @@ router.put(
check('company', 'Company is required')
.not()
.isEmpty(),
check('from', 'From date is required')
check('from', 'From date is required and needs to be from the past')
.not()
.isEmpty()
.custom((value, { req }) => req.body.to ? value < req.body.to : true)
]
],
async (req, res) => {
Expand Down Expand Up @@ -254,9 +255,10 @@ router.put(
check('fieldofstudy', 'Field of study is required')
.not()
.isEmpty(),
check('from', 'From date is required')
check('from', 'From date is required and needs to be from the past')
.not()
.isEmpty()
.custom((value, { req }) => req.body.to ? value < req.body.to : true)
]
],
async (req, res) => {
Expand Down

0 comments on commit 680c808

Please sign in to comment.