Skip to content

Instantly share code, notes, and snippets.

@pablocattaneo
Created January 17, 2019 10:15
Show Gist options
  • Save pablocattaneo/aa18a37cfcaed20b00da615640a837b0 to your computer and use it in GitHub Desktop.
Save pablocattaneo/aa18a37cfcaed20b00da615640a837b0 to your computer and use it in GitHub Desktop.
How to validate that an input is not empty in express using express-validator? #expressValidator
// body('name').not().isEmpty()
// Example
router.post('/insert', [
body('name')
.trim()
.not().isEmpty()
.withMessage('This field is required'),
body('email')
.isEmail()
.normalizeEmail()
], adminController.createEmailsToSend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment