Add validation
This commit is contained in:
parent
45bfff6fc4
commit
29434295c0
2 changed files with 3 additions and 2 deletions
|
@ -35,7 +35,8 @@ defmodule ChoreTracker.Chores.Chore do
|
||||||
:scheduled_at,
|
:scheduled_at,
|
||||||
:next_assignee_id
|
:next_assignee_id
|
||||||
])
|
])
|
||||||
|> validate_required([:name, :emoji, :period, :period_unit, :scheduled_at])
|
|> validate_required([:name, :period, :period_unit, :scheduled_at])
|
||||||
|> validate_length(:emoji, min: 1, max: 1)
|
|> validate_length(:emoji, min: 1, max: 1)
|
||||||
|
|> validate_number(:period, greater_than_or_equal_to: 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ defmodule ChoreTrackerWeb.ChoreLive.FormComponent do
|
||||||
<div>
|
<div>
|
||||||
<p class="text-sm font-semibold leading-6 text-zinc-800">Repeat every</p>
|
<p class="text-sm font-semibold leading-6 text-zinc-800">Repeat every</p>
|
||||||
<div class="flex gap-2 flex-wrap items-stretch">
|
<div class="flex gap-2 flex-wrap items-stretch">
|
||||||
<.input field={@form[:period]} type="number" />
|
<.input field={@form[:period]} type="number" min="1" step="1" />
|
||||||
<.input
|
<.input
|
||||||
field={@form[:period_unit]}
|
field={@form[:period_unit]}
|
||||||
type="select"
|
type="select"
|
||||||
|
|
Loading…
Reference in a new issue