From c9b32cc7f5887eb376a68a5135677ed44fda6674 Mon Sep 17 00:00:00 2001 From: Michael Taylor <mtaylor@michaeltaylor.dev> Date: Wed, 6 Mar 2024 14:03:27 -0500 Subject: [PATCH] fix: do not require pagination when projectIds is used as a query param --- package.json | 2 +- src/validations/projects.validations.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6238c311..4a77f8ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cadt", - "version": "1.7.9", + "version": "1.7.10", "_comment": "DONT CHANGE MAJOR UNLESS DATAMODEL CHANGES: The major version corresponds to the datamodel version your using, so 2.0.0 means it'll use datamodel v2", "private": true, "bin": "build/server.js", diff --git a/src/validations/projects.validations.js b/src/validations/projects.validations.js index b3f8ee50..f0d7cc76 100644 --- a/src/validations/projects.validations.js +++ b/src/validations/projects.validations.js @@ -85,6 +85,18 @@ export const projectsGetQuerySchema = Joi.object({ }), }, ) + .when( + Joi.object({ + projectIds: Joi.array().items(Joi.string()).single().min(1), + }), + { + then: Joi.object(), + otherwise: Joi.object({ + page: Joi.number().required(), + limit: Joi.number().required(), + }), + }, + ) .and('page', 'limit'); export const projectsPostSchema = Joi.object({