Browse Source

Validate for empty category name

sbkwgh 8 năm trước cách đây
mục cha
commit
97061275ef
1 tập tin đã thay đổi với 2 bổ sung0 xóa
  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