using System.ComponentModel.DataAnnotations; namespace AspNetCoreMVC.Models { public class TestModel { [Required] public int Id { get; set; } [Required] [StringLength(20)] public string Name { get; set; } } public class TestViewModel { public List Names { get; set; } } public class SampleViewModel { [Required] [Display(Name = "Product ID to purchase")] public int Id { get; set; } [Range(1, 10, ErrorMessage = "Value should be in 1 ~ 10!")] [Display(Name = "Count")] public int Count { get; set; } } }