Welcome Guest, Not a member yet? Register   Sign In
Model validation vs validationService and required field
#7

(This post was last modified: 11-02-2022, 11:14 PM by BrusterThemand.)

Supposing I have Model Course

//A few of the attributes

        [Key]
        public int CourseId { get; set; }

        [Required(ErrorMessage = "Course title is required")]
        [StringLength(100, MinimumLength = 3, ErrorMessage = "Course title must be between {2} and   
    {1} characters long")]
        [DataType(DataType.Text)]
        [Display(Name = "Course Title")]
        public string CourseTitle { get; set; }

        [Required(ErrorMessage = "Course capacity is required")]
        [Display(Name = "Available places on course")]
        public int CourseCapacity { get; set; }
Would I replicate this exactly in an AddCourseViewModel with the same Data Annotations?

My understanding is the ViewModel will pass the data to the Model (I plan on using AutoMapper), if the data is validated on the omegle.2yu.co ViewModel does it still need validated again when its passed to the Model?

Also if no validation happens on the omeglz echat ViewModel that would mean someone could leave a required field empty? right?
Reply


Messages In This Thread
RE: Model validation vs validationService and required field - by BrusterThemand - 10-10-2022, 12:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB