/**
* Validates queue data for diagnostics with fixed retry intervals.
* @param {Array<Object>} queues An array of queue objects.
* @param {Object} config Configuration object containing retry interval.
* @returns {Array<Object>} Validated queue objects. Returns an empty array if invalid input.
*/
function validateQueues(queues, config) {
if (!Array.isArray(queues)) {
console.error("Invalid input: queues must be an array.");
return [];
}
if (!config || typeof config.retryInterval !== 'number' || config.retryInterval <= 0) {
console.error("Invalid input: config must contain a valid retryInterval (positive number).");
return [];
}
const validatedQueues = [];
for (const queue of queues) {
if (typeof queue !== 'object' || queue === null) {
console.warn("Invalid queue object encountered. Skipping.");
continue;
}
if (typeof queue.name !== 'string' || queue.name.trim() === '') {
console.error("Invalid queue: name must be a non-empty string.");
continue;
}
if (typeof queue.url !== 'string' || queue.url.trim() === '') {
console.error("Invalid queue: url must be a non-empty string.");
continue;
}
if (typeof queue.retryInterval !== 'number' || queue.retryInterval <= 0) {
console.error("Invalid queue: retryInterval must be a positive number.");
continue;
}
validatedQueues.push(queue);
}
return validatedQueues;
}
Add your comment