Current section
Files
Jump to
Current section
Files
web/models/invitation.ex
defmodule Coherence.Invitation do
use Coherence.Web, :model
schema "invitations" do
field :name, :string
field :email, :string
field :token, :string
timestamps
end
@doc """
Creates a changeset based on the `model` and `params`.
If no params are provided, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ %{}) do
model
|> cast(params, ~w(name email token))
|> validate_required([:name, :email])
|> unique_constraint(:email)
|> validate_format(:email, ~r/@/)
end
end