Enforce integer-only values for rent amount field

- Add .int() validation to rentAmount in FormSchema
- Remove decimal formatting (was dividing by 100)
- Change min value from 0 to 1
- Add right text alignment for better numeric display
- Add localization for integer validation error message

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-11-18 23:06:42 +01:00
parent 1c25917093
commit 3540ef596b
4 changed files with 6 additions and 4 deletions

View File

@@ -42,7 +42,7 @@ const FormSchema = (t:IntlTemplateFn) => z.object({
billFwdStrategy: z.enum(["when-payed", "when-attached"]).optional().nullable(),
rentDueNotification: z.boolean().optional().nullable(),
rentDueDay: z.coerce.number().min(1).max(31).optional().nullable(),
rentAmount: z.coerce.number().positive(t("rent-amount-positive")).optional().nullable(),
rentAmount: z.coerce.number().int(t("rent-amount-integer")).positive(t("rent-amount-positive")).optional().nullable(),
addToSubsequentMonths: z.boolean().optional().nullable(),
updateScope: z.enum(["current", "subsequent", "all"]).optional().nullable(),
})

View File

@@ -209,11 +209,11 @@ export const LocationEditForm: FC<LocationEditFormProps> = ({ location, yearMont
id="rentAmount"
name="rentAmount"
type="number"
min="1"
step="0.01"
min="0"
placeholder={t("rent-amount-placeholder")}
className="input input-bordered w-full placeholder:text-gray-600"
defaultValue={location?.rentAmount ? (location.rentAmount / 100).toFixed(2) : ""}
className="input input-bordered w-full placeholder:text-gray-600 text-right"
defaultValue={location?.rentAmount ?? ""}
/>
<div id="rentAmount-error" aria-live="polite" aria-atomic="true">
{state.errors?.rentAmount &&