我希望我的验证模型在输入的 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;
}
有谁知道我如何实现这一目标?
nuget 上有一个用于 Blazor & FluentValidation 的库,可以做到这一点。