自定义类的验证属性

时间:2016-01-18 13:48:02

标签: asp.net-mvc

我上课了:

public class MultilanguageClass{
   public string En { get; set; }
   public string De { get; set; }
}

现在我要创建类:

public class MyShortText{
   [MaxLength(40, ErrorMessage = "Name cannot be longer than 40 characters.")]
   public MultilanguageClass Name { get; set; }
}

public class MyLongText{
   [MaxLength(140, ErrorMessage = "Name cannot be longer than 40 characters.")]
   public MultilanguageClass Name { get; set; }
}

现在我想,这个40个字符对于我的MyShortText类中的En和De是实际的,对于MyLongText类是140。如何实现这个?

0 个答案:

没有答案