Model validation vs validationService and required field |
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? |
Messages In This Thread |
Model validation vs validationService and required field - by Tomv13 - 08-26-2022, 02:58 PM
RE: Model validation vs validationService and required field - by iRedds - 08-28-2022, 01:47 AM
RE: Model validation vs validationService and required field - by kenjis - 08-28-2022, 03:33 PM
RE: Model validation vs validationService and required field - by Tomv13 - 08-29-2022, 12:48 AM
RE: Model validation vs validationService and required field - by kenjis - 08-30-2022, 03:05 PM
RE: Model validation vs validationService and required field - by kenjis - 09-26-2022, 12:24 AM
RE: Model validation vs validationService and required field - by BrusterThemand - 10-10-2022, 12:59 AM
|