Validate number of places being a positive integer

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-06-05 11:38:49 +02:00
parent 03b1f84fba
commit c56e299a09
4 changed files with 209 additions and 204 deletions

View File

@@ -66,6 +66,8 @@ defmodule Mobilizon.Events.EventOptions do
@doc false
@spec changeset(t, map) :: Ecto.Changeset.t()
def changeset(%__MODULE__{} = event_options, attrs) do
cast(event_options, attrs, @attrs)
event_options
|> cast(attrs, @attrs)
|> validate_number(:maximum_attendee_capacity, greater_than_or_equal_to: 0)
end
end