0
votes

I want my validation model to be invalid when the entered value for ActionId is not within in array/list of integers

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?

1

1 Answers

0
votes

There is a library on nuget for Blazor & FluentValidation, that will do it.