Skip to content

Commit

Permalink
input validators for groups and cohorts
Browse files Browse the repository at this point in the history
  • Loading branch information
Baalmart committed Dec 10, 2024
1 parent 99b38f9 commit 2594d91
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/device-registry/routes/v2/cohorts.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ router.put(
.trim()
.isBoolean()
.withMessage("visibility must be Boolean"),
body("groups")
.optional()
.custom((value) => {
return Array.isArray(value);
})
.withMessage("the groups should be an array")
.bail()
.notEmpty()
.withMessage("the groups should not be empty"),
body("network")
.optional()
.notEmpty()
Expand Down Expand Up @@ -169,6 +178,15 @@ router.post(
.trim()
.optional()
.notEmpty(),
body("groups")
.optional()
.custom((value) => {
return Array.isArray(value);
})
.withMessage("the groups should be an array")
.bail()
.notEmpty()
.withMessage("the groups should not be empty"),
body("network")
.trim()
.exists()
Expand Down
18 changes: 18 additions & 0 deletions src/device-registry/routes/v2/grids.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ router.post(
.withMessage(
"admin_level values include but not limited to: province, state, village, county, etc. Update your GLOBAL configs"
),
body("groups")
.optional()
.custom((value) => {
return Array.isArray(value);
})
.withMessage("the groups should be an array")
.bail()
.notEmpty()
.withMessage("the groups should not be empty"),
body("network")
.trim()
.optional()
Expand Down Expand Up @@ -371,6 +380,15 @@ router.put(
.optional()
.notEmpty()
.withMessage("the description should not be empty if provided"),
body("groups")
.optional()
.custom((value) => {
return Array.isArray(value);
})
.withMessage("the groups should be an array")
.bail()
.notEmpty()
.withMessage("the groups should not be empty"),
body("network")
.optional()
.notEmpty()
Expand Down

0 comments on commit 2594d91

Please sign in to comment.