-
-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Labels
need-repro-projectNeed repro projectNeed repro projectquestionQuestion that needs to be answeredQuestion that needs to be answered
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
<BootstrapInput @bind-Value="@Model2.age" ValidateRules="CheckRules"/> 绑定自定义检查正常返回错误

Expected Behavior
No response
Steps To Reproduce
@page "/"
@using System.ComponentModel.DataAnnotations
@using Console = System.Console
<h4>EditForm</h4>
<EditForm Model="@Model" OnSubmit="Submit" FormName="test01">
<DataAnnotationsValidator/>
<ValidationSummary/>
<InputText @bind-Value="Model!.name"/>
<button type="submit">Submit</button>
</EditForm>
<Divider/>
<h4>ValidateForm</h4>
<ValidateForm Model="@Model2" OnValidSubmit="@Submit2">
<BootstrapInput @bind-Value="@Model2.name"/>
<BootstrapInput @bind-Value="@Model2.age" ValidateRules="CheckRules"/>
<Button ButtonType="ButtonType.Submit" Text="提交"></Button>
</ValidateForm>
@code
{
private TestModel Model = new TestModel();
private TestModel Model2 = new TestModel();
private List<IValidator> CheckRules { get; set; } = new List<IValidator>()
{
new FormItemValidator(new ValueCheckAttribute())
};
private void Submit()
{
Console.WriteLine("ok");
}
private Task Submit2(EditContext arg)
{
throw new NotImplementedException();
}
public sealed class TestModel
{
[ValueCheck] public string name { get; set; }
public string age { get; set; }
public string high { get; set; }
public string width { get; set; }
}
public class ValueCheckAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
return new ValidationResult($"The {validationContext.DisplayName} field must be a future date.");
}
}
}
Exceptions (if any)
No response
.NET Version
8.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
need-repro-projectNeed repro projectNeed repro projectquestionQuestion that needs to be answeredQuestion that needs to be answered