One approach that gets some abstraction is to have a ViewModel made up of your business model class, including other relevant viewing information.
class MyObject { public int ID {get;set} [Required] [StringLength(512)] public string Name {get;set;} } class MyViewModel // ViewModel for a specific view { public MyObject MyModel {get;set;}
Then in the ViewModel link respectively.
@model My.Namespace.MyViewModel Hello @model.MyModel.Name !!!
Thus, you will indicate only your confirmations and / or data annotations in your business class in one place.
If you want to have a different validation, this will require some strategy to selectively apply validation logic.
source share