From fd30646d8a27556e385ab36e70bf3932d20513e3 Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Fri, 6 Mar 2026 16:21:37 -0800 Subject: [PATCH] Fix number field validation: strip text from numeric answers Number inputs (type="number") were getting answers like "5 years" instead of "5", causing LinkedIn validation errors. Now: - AI gets "(must be a number, no text or units)" hint - Answers are stripped to digits before filling Co-Authored-By: Claude Opus 4.6 --- lib/form_filler.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/form_filler.mjs b/lib/form_filler.mjs index c0abdfd..ea4b5c0 100644 --- a/lib/form_filler.mjs +++ b/lib/form_filler.mjs @@ -568,12 +568,18 @@ Answer:`; continue; } - const formatHint = field.placeholder ? `(format: ${field.placeholder})` : ''; + let formatHint = field.placeholder ? `(format: ${field.placeholder})` : ''; + if (field.type === 'number') formatHint = '(must be a number, no text or units)'; let answer = this.answerFor(lbl); if (!answer && field.required) { answer = await this.aiAnswerFor(formatHint ? `${lbl} ${formatHint}` : lbl); if (answer) this.saveAnswer(lbl, answer); } + // For number fields, extract just the numeric value + if (answer && field.type === 'number') { + const num = String(answer).replace(/[^\d.]/g, ''); + if (num) answer = num; + } if (answer && answer !== this.profile.cover_letter) { const el = await byTag(field.tag); if (!el) continue;