当输入的ActionId 值不在整数数组/列表中时,我希望验证模型无效
public class AddTerminalInput
{
private List<int> actionIds;
public AddTerminalInput(List<int> actionIds)
{
this.actionIds = actionIds;
}
[Required(AllowEmptyStrings = false)]
public string TerminalId { get; set; } = "";
[Required(AllowEmptyStrings = false)]
public string TerminalName { get; set; } = "";
// ActionId should be only valid if the value is within actionIds
public int ActionId { get; set; } = 1;
}
有人知道我能做到这一点吗?
答案 0 :(得分:0)
在nuget上有一个用于Blazor和FluentValidation的库。