Validates and parses raw string input into a bounded integer reply target. Reuse when configuring messaging automation targets and timeouts.
// Source: https://github.com/ArnasDon/wacrm | License: MIT | Copyright 2026 Arnas Donauskas
// Provided via justclaw.it.com; keep this notice with the code.
export const REPLY_TARGET_MIN = 1;
export const REPLY_TARGET_MAX = 1440;
export function parseReplyTarget(raw: string): number | null {
const trimmed = raw.trim();
if (!/^\d+$/.test(trimmed)) return null;
const value = Number(trimmed);
return value >= REPLY_TARGET_MIN && value <= REPLY_TARGET_MAX ? value : null;
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key