From 46888c31dbcf7bd85d53f07683b5997e00d63866 Mon Sep 17 00:00:00 2001 From: Bekiboo Date: Thu, 22 Jan 2026 09:19:36 +0300 Subject: [PATCH] fix: update search query validation to disallow empty queries --- .../src/controllers/UserController.ts | 8 ++++---- .../pictique-api/src/services/UserService.ts | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/platforms/pictique-api/src/controllers/UserController.ts b/platforms/pictique-api/src/controllers/UserController.ts index 3fee4401..0f519b87 100644 --- a/platforms/pictique-api/src/controllers/UserController.ts +++ b/platforms/pictique-api/src/controllers/UserController.ts @@ -43,10 +43,10 @@ export class UserController { } // Validate search query length - if (q.trim().length < 2) { + if (q.trim().length < 1) { return res .status(400) - .json({ error: "Search query must be at least 2 characters long" }); + .json({ error: "Search query cannot be empty" }); } // Parse and validate pagination parameters @@ -120,10 +120,10 @@ export class UserController { } // Validate search query length - if (q.trim().length < 2) { + if (q.trim().length < 1) { return res .status(400) - .json({ error: "Search query must be at least 2 characters long" }); + .json({ error: "Search query cannot be empty" }); } // Parse and validate pagination parameters diff --git a/platforms/pictique-api/src/services/UserService.ts b/platforms/pictique-api/src/services/UserService.ts index d68f1bc1..f465354a 100644 --- a/platforms/pictique-api/src/services/UserService.ts +++ b/platforms/pictique-api/src/services/UserService.ts @@ -70,8 +70,8 @@ export class UserService { // Sanitize and trim the search query const searchQuery = query.trim(); - // Return empty array if query is too short or empty - if (searchQuery.length < 2) { + // Return empty array if query is empty + if (searchQuery.length < 1) { return []; } @@ -156,8 +156,8 @@ export class UserService { // Sanitize and trim the search query const searchQuery = query.trim(); - // Return 0 if query is too short or empty - if (searchQuery.length < 2) { + // Return 0 if query is empty + if (searchQuery.length < 1 ) { return 0; } @@ -188,7 +188,7 @@ export class UserService { // Sanitize and trim the search query const searchQuery = query.trim(); - // Return empty array if query is too short + // Return empty array if query is empty if (searchQuery.length < 1) { return []; } @@ -240,8 +240,8 @@ export class UserService { // Sanitize and trim the search query const searchQuery = query.trim(); - // Return empty array if query is too short or empty - if (searchQuery.length < 2) { + // Return empty array if query is empty + if (searchQuery.length < 1) { return []; } @@ -306,8 +306,8 @@ export class UserService { // Sanitize and trim the search query const searchQuery = query.trim(); - // Return 0 if query is too short or empty - if (searchQuery.length < 2) { + // Return 0 if query is empty + if (searchQuery.length < 1 ) { return 0; }