From f1b732f450ea9bef8a82fddfd720570448df40b1 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 27 Jul 2024 15:48:48 +0200 Subject: [PATCH] Fix input length validation for polls --- .gitignore | 1 + CHANGELOG.md | 4 ++++ lib/claper/polls/poll.ex | 1 + lib/claper/polls/poll_opt.ex | 1 + lib/claper_web/live/poll_live/form_component.html.heex | 2 +- 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 383c2792..b7b33754 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ test/e2e/node_modules .DS_Store priv/static/.well-known/apple-developer-merchantid-domain-association priv/static/loaderio-eb3b956a176cdd4f54eb8570ce8bbb06.txt +.elixir_ls diff --git a/CHANGELOG.md b/CHANGELOG.md index d7cc42ba..90a249db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - LTI 1.3 support - New layout for presentation manager +### Fixes and improvements + +- Fix input length validation for polls + ## v2.0.1 ### Features diff --git a/lib/claper/polls/poll.ex b/lib/claper/polls/poll.ex index 083052a2..4239500c 100644 --- a/lib/claper/polls/poll.ex +++ b/lib/claper/polls/poll.ex @@ -37,5 +37,6 @@ defmodule Claper.Polls.Poll do |> cast(attrs, [:title, :presentation_file_id, :position, :enabled, :total, :multiple]) |> cast_assoc(:poll_opts, required: true) |> validate_required([:title, :presentation_file_id, :position]) + |> validate_length(:title, max: 255) end end diff --git a/lib/claper/polls/poll_opt.ex b/lib/claper/polls/poll_opt.ex index c2901dab..6fbb028e 100644 --- a/lib/claper/polls/poll_opt.ex +++ b/lib/claper/polls/poll_opt.ex @@ -31,5 +31,6 @@ defmodule Claper.Polls.PollOpt do poll_opt |> cast(attrs, [:content, :vote_count, :poll_id]) |> validate_required([:content]) + |> validate_length(:content, max: 255) end end diff --git a/lib/claper_web/live/poll_live/form_component.html.heex b/lib/claper_web/live/poll_live/form_component.html.heex index 454ae998..9ffed811 100644 --- a/lib/claper_web/live/poll_live/form_component.html.heex +++ b/lib/claper_web/live/poll_live/form_component.html.heex @@ -26,7 +26,7 @@ <%= inputs_for f, :poll_opts, fn i -> %>
-
+