dotnet / dotnet/aspnetcore

Form validation for Blazor (EditForm) to include validation error message for data annotations and custom validation at the same time

Open
#66,966 3 comments 0 reactions 0 assignees View on GitHub
area-blazor Needs: Author Feedback
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Form-validation-for-Blazor-EditForm-to/11077540)._

---
Can we please update the Blazor validation (EditForm) to include validation error message for both data annotations and custom validation at the same time. Currently the data annotation validation errors appear initially and when these are resolved, the custom validation errors show. It would be more user friendly for all validations to appear at the same time the editContext.Validate() is called. Here is an example form:

```




Code








Name







Save

```

with the Model:

```
public class TypeModel : IValidatableObject
{
public int TypeId { get; set; }
[Required]
public string Code { get; set; } = string. Empty;
public string Name { get; set; } = string. Empty;
public bool Active { get; set; }
public DateTime ModifiedDateTime { get; set; }
public bool IsPendingSync { get; set; }

public IEnumerable<ValidationResult> Validate(ValidationContext context)
{
var results = new List<ValidationResult>();

if (Name == null || Name == string. Empty)
{
results. Add(new ValidationResult("Name is required.", new[] { nameof(Name) }));
}

return results;
}
}

```

Here is the 'Handle Submit' method:

```
private async Task HandleSubmit()
{
var isValid = editContext.Validate(); // 🔥 THIS is the key

if (!isValid)
return;

await SaveUpdate();
}
```

If save is selected without entering any data into the InputText fields, the ‘Code’ field shows an error message but not ‘Name’. Once ‘Code’ has a value, then the ‘Name’ shows an error message.

I’m using .Net 10 and the latest Visual Studio 2026 Insiders \[11709.129\].

Thanks for considering.

---
### Original Comments

#### Feedback Bot on 4/21/2026, 00:57 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about a week on our next steps.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.