feat: add context methods to mutate rooms
Also, improve user input validation.
This commit is contained in:
@@ -13,6 +13,11 @@ defmodule Slax.Chat.Room do
|
||||
def changeset(room, attrs) do
|
||||
room
|
||||
|> cast(attrs, [:name, :topic])
|
||||
|> validate_required([:name, :topic])
|
||||
|> validate_required([:name])
|
||||
|> validate_length(:name, max: 80)
|
||||
|> validate_format(:name, ~r/\A[a-z0-9-]+\z/,
|
||||
message: "can only contain lowercase letters, numbers, and dashes"
|
||||
)
|
||||
|> validate_length(:topic, max: 200)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user