[Required]
public string CompanyName { set; get; }
[DataType(DataType.Url)]
public string WebAddress { get; set; }
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
[MaxLength(20)]
public Decimal Phone { get; set; }
[Required]
public Decimal AvarageWages {get; set;}
现在我需要使用默认值创建字段(平均工资),例如100 - 1000,1000-2000等。我将如何验证?
答案 0 :(得分:3)
要验证范围值,您可能需要使用Range
属性:
[Range(0, 100)]
public int Value { get; set; }
[Range(typeof(DateTime), "1/1/2011", "1/1/2012", ErrorMessage = "Out of Range!")]
public DateTime DateOfSomething { get; set; }