n8n-nodes-zalo-nnt
Version:
Unofficial Zalo integration for n8n - Send messages, manage groups, user operations with QR login. No API key required, works via browser simulation.
31 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateThreadId = validateThreadId;
exports.validatePositiveInt = validatePositiveInt;
exports.parseStickerIds = parseStickerIds;
function validateThreadId(threadId) {
if (!threadId || threadId.trim() === '') {
throw new Error('ID cuộc trò chuyện (threadId) không được để trống');
}
}
function validatePositiveInt(value, fieldName) {
if (!Number.isInteger(value) || value <= 0) {
throw new Error(`${fieldName} phải là số nguyên dương, nhận được: ${value}`);
}
}
function parseStickerIds(raw) {
const ids = raw
.split(',')
.map((id) => id.trim())
.filter((id) => id !== '')
.map((id) => Number(id));
if (ids.length === 0) {
throw new Error('Danh sách ID sticker không được để trống');
}
const invalid = ids.filter((id) => !Number.isInteger(id) || id <= 0);
if (invalid.length > 0) {
throw new Error(`ID sticker không hợp lệ: ${invalid.join(', ')}`);
}
return ids;
}
//# sourceMappingURL=validator.js.map