I am working in VisualStudio with a Product object from a model. I am very unfamiliar with custom attributes. I would like to restrict a Product's name, for example, to 3 words maximum.
[Required (ErrorMessage="Product name is required.")]
[Display(Name = "Product Name")]
[StringLength(30, ErrorMessage = "The {0} must be between {2} and {1} characters.", MinimumLength = 5)]
[ExcludeChar("/.,!@#$%", ErrorMessage = "Name contains invalid character.")]
// Custom annotation.
public object ProductName { get; set; }