sanitizeQuery
sanitizeQuery(obj)
sanitizeQuery(obj)
Sanitizes a query object by removing empty keys and parsing numeric string values to numbers. It combines the functionality of removeEmptyKeys
to clean up the object and parseNumValues
to convert numeric string values to numbers, ensuring a clean and consistent query object.
Arguments
obj
(Record<string, any>
): The query object to be sanitized, containing key-value pairs to clean and parse.
Returns
Record<string, any>
: The sanitized query object with empty keys removed and numeric values parsed.
Example
Usage
Notes
The
sanitizeQuery
function provides a comprehensive sanitization process for query objects, ensuring data cleanliness and type consistency.It removes empty keys and parses numeric string values to numbers, enhancing the quality and reliability of query data.
This function is valuable for preparing query parameters before processing or interacting with external systems.
Last updated
Was this helpful?