[英]Blazor server side extended validation
I want my validation model to be invalid when the entered value for ActionId is not within in array/list of integers当 ActionId 的输入值不在整数数组/列表中时,我希望我的验证 model 无效
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;
}
does anybody know how I can achive this?有人知道我怎么能做到这一点吗?
There is a library on nuget for Blazor & FluentValidation, that will do it. nuget 上有一个用于 Blazor 和 FluentValidation 的库,可以做到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.