added input validation for poll creation

This commit is contained in:
Sarah Faey 2023-01-15 10:04:03 +01:00
parent 2a69ccc1b6
commit 1f5a1f4fe2
3 changed files with 37 additions and 5 deletions

View file

@ -1,4 +1,6 @@
namespace Lieb.Models.Poll
using System.ComponentModel.DataAnnotations;
namespace Lieb.Models.Poll
{
public enum AnswerType
{
@ -8,6 +10,9 @@
public class Poll
{
public int PollId { get; set; }
[Required]
[StringLength(200, ErrorMessage = "Question too long (200 character limit).")]
public string Question { get; set; }
public ICollection<PollOption> Options { get; set; } = new List<PollOption>();
public ICollection<PollAnswer> Answers { get; set; } = new List<PollAnswer>();

View file

@ -1,8 +1,13 @@
namespace Lieb.Models.Poll
using System.ComponentModel.DataAnnotations;
namespace Lieb.Models.Poll
{
public class PollOption
{
public int PollOptionId { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Option too long (100 character limit).")]
public string Name { get; set;} = string.Empty;
}
}