Skip to content

Commit

Permalink
Enforce positive number inputs in predict form
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssadsouza committed Jan 5, 2025
1 parent a4c08cc commit ba00aa0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/src/components/Inputs/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function TextInput({
<input
{...register(fieldName, {
required: requiredErrorMessage,
valueAsNumber: type === "number", // Ensures input is treated as a number
validate: type == "number" ? ((value) => value > 0 || "The number must be positive") : undefined,
})}
placeholder={placeholder}
className="transition-all py-1 px-3 rounded-full border hover:bg-slate-50 focus:bg-white focus dark:bg-slate-600 dark:hover:bg-slate-500 dark:focus:bg-slate-600 dark:border-slate-500"
Expand Down

0 comments on commit ba00aa0

Please sign in to comment.