Real-Dev-Squad / website-backend

The backend code for all our website-related apps
https://api.realdevsquad.com/
MIT License
55 stars 258 forks source link

Enforce Boolean Query Parameters Using Joi Transformations #2272

Open VinuB-Dev opened 15 hours ago

VinuB-Dev commented 15 hours ago

Issue Description

Currently, query parameters intended to represent boolean values (e.g., departed=true, dev=true) are treated as strings instead of being parsed as actual booleans. This limitation arises because the backend does not support query parameter transformations to boolean types. For instance, the dev flag is defined as joi.string() instead of joi.boolean() in the validation layer, causing boolean-like inputs to remain as strings.

This behavior leads to inconsistent handling of boolean parameters and increases the risk of errors in processing such values. Supporting actual boolean parsing for query parameters will require transformations in the backend to convert "true"/"false" strings to their respective boolean values.

While this is not a critical issue, it is better addressed as an enhancement task to align with expected behaviors.

Expected Behavior

The API should accept query parameters as proper booleans instead of strings ("true" or "false") for flags like departed and dev. The backend should automatically transform and validate these parameters using joi.boolean().

Current Behavior

Currently, query parameters intended to be booleans (e.g., departed, dev) are handled as strings ("true" or "false"). There is no native boolean support in query parameters, and the transformation to actual booleans is not implemented.

Screenshots

Current validation schema showing the dev flag and profile param handled as a string instead of a boolean.

Image

Reproducibility

Steps to Reproduce

  1. Pass a boolean query parameter (departed=true) to the API.
  2. Observe that it is treated as a string instead of a boolean.

Severity/Priority

Additional Information

Checklist