diff --git a/aspnet/mvc/overview/getting-started/introduction/adding-validation.md b/aspnet/mvc/overview/getting-started/introduction/adding-validation.md index d56e7abe22..69d1750144 100644 --- a/aspnet/mvc/overview/getting-started/introduction/adding-validation.md +++ b/aspnet/mvc/overview/getting-started/introduction/adding-validation.md @@ -37,7 +37,7 @@ Open the *Movie.cs* file. Notice the [`System.ComponentModel.DataAnnotations`](h Now update the `Movie` class to take advantage of the built-in [`Required`](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.requiredattribute.aspx), [`StringLength`](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx), [RegularExpression](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.regularexpressionattribute.aspx), and [`Range`](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.rangeattribute.aspx) validation attributes. Replace the `Movie` class with the following: -[!code-csharp[Main](adding-validation/samples/sample1.cs?highlight=8,22-24,30-31,37-38)] +[!code-csharp[Main](adding-validation/samples/sample1.cs?highlight=5,13-15,18-19,22-23)] The [`StringLength`](https://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.stringlengthattribute.aspx) attribute sets the maximum length of the string, and it sets this limitation on the database, therefore the database schema will change. Right click on the **Movies** table in **Server explorer** and click **Open Table Definition**: diff --git a/aspnet/mvc/overview/getting-started/introduction/adding-validation/samples/sample1.cs b/aspnet/mvc/overview/getting-started/introduction/adding-validation/samples/sample1.cs index 48f65bd8b8..48510d0912 100644 --- a/aspnet/mvc/overview/getting-started/introduction/adding-validation/samples/sample1.cs +++ b/aspnet/mvc/overview/getting-started/introduction/adding-validation/samples/sample1.cs @@ -2,39 +2,24 @@ public class Movie {     public int ID { get; set; } - - -     [StringLength(60, MinimumLength = 3)]     public string Title { get; set; } - - -     [Display(Name = "Release Date")]     [DataType(DataType.Date)]     [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]     public DateTime ReleaseDate { get; set; } - - - - -    [RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$")] + +    [RegularExpression(@"^[A-Z]+[a-zA-Z'\s]*$")]     [Required]     [StringLength(30)]     public string Genre { get; set; } - - -     [Range(1, 100)]     [DataType(DataType.Currency)]     public decimal Price { get; set; } - - - -    [RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$")] +    [RegularExpression(@"^[A-Z]+[a-zA-Z'\s]*$")]     [StringLength(5)]     public string Rating { get; set; } -} \ No newline at end of file +}