Hey Chinedu,
I echo sentiment of others regarding the endless search for finding a tutorial that made sense and was easy to implement! Thank you! Would I check for duplicates in the database in this file as well?
PS: I found this: express-validator.github.io/docs/c...
how would we incorporate it into what we have?
I'm sure your slammed with requests like this - no worries if you don't have the bandwidth to reply
hey Chinedu - kept searching and found my answer! I am fired up - see below if anyone else is interested:
const { body, check, validationResult } = require('express-validator') const Team = require('../models/Team')
const teamValidationRules = () => {
return [ // is name present check('name'," a string 'name' is required.") .notEmpty().isString() .custom( async (value, {req}) => { const check = await Team.findOne({name: value})
if(check){ return Promise.reject('Name is already in use'); } }),
Great job, I just saw your comment, good to know you've been able to tackle it
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Chinedu,
I echo sentiment of others regarding the endless search for finding a tutorial that made sense and was easy to implement! Thank you! Would I check for duplicates in the database in this file as well?
PS: I found this:
express-validator.github.io/docs/c...
how would we incorporate it into what we have?
I'm sure your slammed with requests like this - no worries if you don't have the bandwidth to reply
hey Chinedu - kept searching and found my answer! I am fired up - see below if anyone else is interested:
const { body, check, validationResult } = require('express-validator')
const Team = require('../models/Team')
const teamValidationRules = () => {
return [
// is name present
check('name'," a string 'name' is required.")
.notEmpty().isString()
.custom(
async (value, {req}) => {
const check = await Team.findOne({name: value})
Great job, I just saw your comment, good to know you've been able to tackle it