【发布时间】:2017-04-11 03:17:56
【问题描述】:
我使用 asp.net core web API 创建了一个模型,我必须验证属性取决于 bool 数据类型属性值。
如果 IsWaitingList 属性为 true ,则 WaitingListEncounterOrOtherEncounter 属性为必填属性,否则不是必填字段。
public class CenterConfiguration
{
public Guid Id { get; set; } = Guid.NewGuid();
public bool? IsWaitingList { get; set; }
[Required(ErrorMessage = "Please enter waiting list encounter or other encounter")]
public int WaitingListEncounterOrOtherEncounter { get; set; }
}
如果有人知道,请告诉我。
【问题讨论】:
标签: c# asp.net-mvc-4 asp.net-web-api2 asp.net-core-webapi