Ver código fonte

Validate for empty category name

sbkwgh 8 anos atrás
pai
commit
97061275ef
1 arquivos alterados com 2 adições e 0 exclusões
  1. 2 0
      routes/category.js

+ 2 - 0
routes/category.js

@@ -39,6 +39,8 @@ router.post('/', async (req, res) => {
 			validationErrors.push(Errors.missingParameter('name'))
 		} else if(typeof req.body.name !== 'string') {
 			validationErrors.push(Errors.invalidParameterType('name', 'string'))
+		} else if(!req.body.name.length) {
+			validationErrors.push(Errors.parameterLengthTooSmall('name', 'string'))
 		}
 
 		if(validationErrors.length) throw Errors.VALIDAITON_ERROR