fix: validate E.164 format for Signal account number during onboarding

Previously, the Signal account prompt only validated that some text was
entered, allowing invalid values like "ok" to be stored. This caused the
Signal channel to fail with confusing errors.

Now the prompt validates that the input is a valid E.164 phone number
(using the existing normalizeE164 utility) and provides a helpful error
message if validation fails.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Duarte Martins 2026-01-26 13:13:11 +01:00
parent 6859e1e6a6
commit 82ac6c6a1d

View File

@ -235,12 +235,20 @@ export const signalOnboardingAdapter: ChannelOnboardingAdapter = {
}
if (!account) {
account = String(
const rawAccount = String(
await prompter.text({
message: "Signal bot number (E.164)",
validate: (value) => (value?.trim() ? undefined : "Required"),
validate: (value) => {
const trimmed = value?.trim();
if (!trimmed) return "Required";
if (!normalizeE164(trimmed)) {
return "Invalid E.164 phone number (must start with + and country code, e.g. +15555550123)";
}
return undefined;
},
}),
).trim();
account = normalizeE164(rawAccount) ?? rawAccount;
}
if (account) {