fix: accept euro sign and dot thousands separators in amounts, clearer loan capital error
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4837a5cf22
commit
c3c371aefe
4 files changed
+16
-4
No files matched your search
@@ -50,7 +50,7 @@ const optionalEuro = (s: string) => (s.trim() === "" ? null : (parseEuro(s) ?? u
|
||||
export async function saveLoan(input: LoanFormInput, today: string = todayParis()): Promise<Result<{ id: string }>> {
|
||||
if (!input.name.trim()) return { ok: false, error: "Le nom est obligatoire." };
|
||||
const principal = parseEuro(input.principal);
|
||||
if (principal === null) return { ok: false, error: "Capital invalide." };
|
||||
if (principal === null) return { ok: false, error: "Capital emprunté invalide (ex. 40000 ou 40 000,00)." };
|
||||
const rateText = input.annualRate.trim().replace(",", ".");
|
||||
const rate = /^\d+(\.\d{1,3})?$/.test(rateText) ? Number(rateText) : NaN;
|
||||
if (!(rate >= 0 && rate < 100)) return { ok: false, error: "Taux invalide." };
|
||||
|
||||
Reference in new issue
Block a user