middleware/validate/store/update/information/name

mail@pastecode.io avatar
unknown
plain_text
25 days ago
419 B
1
Indexable
Never
const { body, validationResult } = require('express-validator')

const updateStoreNameValidator = [
  // Validate name
  body("name")
    .isString()
    .withMessage("name must be a string"),
    
  (req, res, next) => {
    const errors = validationResult(req)
    if (!errors.isEmpty()) {
      return res.status(400).json({ errors: errors.array() })
    }
    next()
  }
]

module.exports = updateStoreNameValidator
Leave a Comment