Skip to content

Rework Blazor validation docs and add .NET 11 features - #37488

Merged
oroztocil merged 11 commits into
mainfrom
oroztocil/validation-docs-rework
Sep 22, 2026
Merged

oroztocil merged 11 commits into
mainfrom
oroztocil/validation-docs-rework

Conversation

@oroztocil

@oroztocil oroztocil commented Aug 17, 2026

Copy link
Copy Markdown
Member

Reworks the validation documentation and adds coverage for the validation features introduced in .NET 11.

Motivation

The main Blazor validation article had grown to more than 1,500 lines as new scenarios were added over several releases. It mixed the common form workflow with lower level APIs and specialized tutorials, making basic guidance difficult to find and related concepts difficult to distinguish.

Before this rework:

  • Basic data annotations guidance was interleaved with direct EditContext usage, validator components, asynchronous validation, client side validation, and remote validation instead of progressing from common to advanced tasks.
  • Important behavior, including what AddValidation changes and how DataAnnotationsValidator selects its validation path, was buried far from the first examples.
  • Model based validation rules and imperative ValidationMessageStore patterns were spread across several sections, which obscured the distinction between the two approaches.
  • The remote validation walkthrough occupied a large part of the main article and mixed validation concepts with authentication, proxy, hosting, and multi project setup.
  • Nested validation, localization, custom rules, and generated metadata were documented as Blazor concerns even though the same Microsoft.Extensions.Validation behavior also applies to Minimal APIs.
  • New .NET 11 features were either undocumented or described with APIs that changed before release.

A companion pull request, dotnet/blazor-samples#662, contains the referenced samples. This pull request shouldn't merge first because the new :::code references depend on those sample files.

New documentation layout

Article Purpose
Blazor forms validation The common workflow: data annotations, direct EditContext validation, messages, field appearance, validation state, and form submission
Advanced form validation Reusable validator components and the end-to-end remote validation tutorial
Client-side form validation in static SSR The .NET 11 browser-validation feature, including custom client rules, opt-outs, and limitations
Validation in ASP.NET Core Shared Microsoft.Extensions.Validation and DataAnnotations guidance for Blazor and Minimal APIs

The forms index and related articles route readers to the appropriate level instead of placing every scenario in one long Blazor article. Version-specific content remains available from ASP.NET Core 3.1 through 11.0.

Moved

  • Generated validation metadata, nested object graphs, model-based custom rules, asynchronous validation, and localization moved to the shared validation article because they apply to both Blazor and Minimal APIs.
  • Validator-component and remote-service walkthroughs moved to the advanced Blazor article because they combine lower-level APIs into specialized patterns.
  • Static SSR client validation moved to its own .NET 11 article because its behavior and extensibility are specific to browser validation in that rendering mode.
  • InputText input-event guidance moved to the forms binding article because it describes binding behavior rather than validation.
  • Validation messages, CSS classes, validation-state reactions, and submission handling are consolidated in the main Blazor article because they are common form tasks.

Dropped or reduced

  • Repeated framework-specific explanations were replaced with shared guidance and focused links to reduce duplication and drift.
  • The remote-validation tutorial was reduced to the validation boundary and a lean Interactive WebAssembly plus same-origin API sample, avoiding unrelated authentication, proxy, and hosting complexity in the .NET 11 path.
  • Large inline sample listings were replaced with maintained sample files where the surrounding code wasn't necessary to explain the validation concept.
  • Obsolete package guidance, removed APIs, and implementation details that users don't act on were removed or rewritten against the shipping APIs.

Added for .NET 11

  • Client-side validation for static SSR forms, including custom .NET and JavaScript rules.
  • Asynchronous validation with AsyncValidationAttribute, IAsyncValidatableObject, and EditContext, including ValidateAsync, field and form pending and faulted state, and the default field state CSS classes.
  • Built-in validation-message localization, resource lookup conventions, and multi-assembly guidance.

Documentation usability experiment

I tested the updated articles by assigning a set of questions and programming tasks involving Blazor form validation to a group of isolated AI agents that intentionally ran with cheap models (Haiku, Flash, Luna, etc.) and had no access to internet search. The goal was to ensure that the docs are complete and easy to understand. I did three rounds of this experiment and updated the docs with additional details, code examples, or simply clarification. I stopped when all the agents were able to produce good results.

Verification

The articles were rendered and checked for every supported version from ASP.NET Core 3.1 through 11.0. Moniker ranges, code fences, links, anchors, sample references, and version-specific API availability were verified, and the new samples were built and exercised.


Internal previews

Toggle expand/collapse
File Preview link
aspnetcore/blazor/components/component-disposal.md Learn preview
aspnetcore/blazor/forms/binding.md Learn preview
aspnetcore/blazor/forms/index.md Learn preview
aspnetcore/blazor/forms/validation-advanced.md Learn preview
aspnetcore/blazor/forms/validation-client-side.md Learn preview
aspnetcore/blazor/forms/validation.md Learn preview
aspnetcore/blazor/globalization-localization.md Learn preview
aspnetcore/fundamentals/localization/make-content-localizable.md Learn preview
aspnetcore/fundamentals/minimal-apis.md Learn preview
aspnetcore/fundamentals/validation.md Learn preview
aspnetcore/release-notes/aspnetcore-11.md Learn preview
aspnetcore/release-notes/aspnetcore-11/includes/blazor.md Learn preview
aspnetcore/release-notes/aspnetcore-11/includes/validation-attributes-no-longer-experimental.md Learn preview
aspnetcore/release-notes/aspnetcore-11/includes/validation-localization.md Learn preview
aspnetcore/release-notes/aspnetcore-5.0.md Learn preview
aspnetcore/release-notes/aspnetcore-7.0.md Learn preview
aspnetcore/toc.yml Learn preview

Build report

@guardrex guardrex self-assigned this Aug 17, 2026
@guardrex

This comment was marked as resolved.

@oroztocil

Copy link
Copy Markdown
Member Author

@guardrex Please note that this is just a rough draft and work in progress. So please don't spend time reviewing it before I undraft the PR. 🙂

I will be OOF until August 24 so I will get to finish only then, unfortunately.

@oroztocil
oroztocil force-pushed the oroztocil/validation-docs-rework branch from 3771431 to 1d6acd7 Compare August 25, 2026 11:26
@oroztocil
oroztocil force-pushed the oroztocil/validation-docs-rework branch from 1d6acd7 to f63dc43 Compare September 16, 2026 17:48
@oroztocil
oroztocil force-pushed the oroztocil/validation-docs-rework branch from f63dc43 to 5f961c1 Compare September 16, 2026 18:05
oroztocil and others added 6 commits September 17, 2026 16:46
Follow-up to the validation docs restructure. Reduces article length,
orders sections from the simplest and most common cases to the most
advanced, and moves sample code out of the articles.

Blazor forms validation

* Merges the three sections that described the DataAnnotationsValidator
  component into one, with validation order and short-circuiting as a
  subsection instead of the last section in the article.
* Folds the IValidatableObject stub and "Determine if a form field is
  valid" into the sections they belong to.
* Moves the table that routes readers to nested objects, localization,
  client-side validation, and the advanced article near the top, so a
  reader looking for one of those finds it early.
* Documents the default validation CSS classes, which were previously
  described only for static SSR.
* Moves the FieldCssClassProvider guidance to the advanced article, since
  it customizes validation rather than explaining it.

Advanced form validation

* The remote validation walkthrough now references sample projects instead
  of carrying its code inline, and gains subsections for each step.
* The per-field asynchronous validation example shows only what differs
  from the form-level example rather than repeating it.
* The FieldCssClassProvider section arrives here, references its sample
  files, and gains subsections.

Client-side validation in static SSR

* The custom rule example references its sample files.

Validation in ASP.NET Core

* Condenses multi-assembly registration to one pattern with short notes for
  Minimal APIs and Blazor, instead of two near-identical walkthroughs.

Rendered length, .NET 11: 607 to 438, 904 to 714, 283 to 232, and 521 to
483 lines respectively. Verified across all supported versions that no
in-page anchor is broken, moniker blocks are balanced, and every active
sample reference resolves.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 608096b5-db3e-4006-adaa-b4da0309ff87
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1616697-b97e-43c8-bba6-eadce0a68d2c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1616697-b97e-43c8-bba6-eadce0a68d2c
@oroztocil
oroztocil force-pushed the oroztocil/validation-docs-rework branch from 5f961c1 to 8a59e0e Compare September 17, 2026 14:47
@oroztocil oroztocil changed the title Restructure and trim the Blazor validation articles Rework Blazor validation docs and add .NET 11 features Sep 17, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1616697-b97e-43c8-bba6-eadce0a68d2c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1616697-b97e-43c8-bba6-eadce0a68d2c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b1616697-b97e-43c8-bba6-eadce0a68d2c
@oroztocil
oroztocil marked this pull request as ready for review September 18, 2026 15:25
@oroztocil

oroztocil commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Hi @guardrex! I wanted to have this ready sooner, but here is my proposed rework of the Blazor form validation docs, including some parts of the new shared ASP/MEV validation article.

I know this is a lot - and probably cannot be read in the diff mode. The details are probably not perfect, and I defer to your expertise there. However, I truly think that the overall direction is a significant improvement in clarity and usability of the validation section.

I am also not 100% sure that I (or my copilot) did everything correctly on the technical side (the special markup, references, etc.). Feel free to push fixes and stylistic improvements to the branch. If you would want me to rewrite or extend something content-wise, let me know. Thanks!

@guardrex

Copy link
Copy Markdown
Collaborator

Thanks for doing all of this work, @oroztocil! I'm sure that it will be a vast improvement.

I'm already gone for the weekend 🏖️😄. I'll review first thing on Monday morning. Have a great weekend! 🍻

@gewarren

Copy link
Copy Markdown
Contributor

Closing and reopening to fix workflows.

@gewarren gewarren closed this Sep 18, 2026
@gewarren gewarren reopened this Sep 18, 2026
@guardrex

Copy link
Copy Markdown
Collaborator

I'm going to close and re-open to rebuild this with the sample updates in place (dotnet/blazor-samples#662).

@oroztocil

Copy link
Copy Markdown
Member Author

@guardrex Regarding the broken samples from the blazor-samples repo: Would it work for you if I ask my copilot (which has the full context of the overall change) to make all the new/modified code examples in this PR inline, so that we can fully revert the blazor-samples PR, get this PR merged, and then look at updating the samples correctly later.

@guardrex

guardrex commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Yes ... but since I'm reviewing now, wouldn't it be best to let me get my review done first? That way, you could react to my feedback first. It should result in a cleaner update. I should have my review in to you within a couple of hours.

@oroztocil

Copy link
Copy Markdown
Member Author

@guardrex Yes, that sounds good. Thanks! 🙂

@guardrex guardrex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wowzers, @oroztocil! 🤩 Quite an amazing set of updates! I ❤️ everything that you've done here, and I'm sure @danroth27 is excited as well to see these improvements and new content going in.

I just have NITs here and there and some grammatical suggestions on the diff. For things like the header cross-linking and underscore naming of fields, let's go ahead with what you're doing. If I need to make updates, I'll do them separately with Wade and Tom later.

A few more things to do here, too ...........

Please update the ms.dates for the following articles to today:

  • aspnetcore/blazor/forms/binding.md
  • aspnetcore/blazor/forms/index.md
  • aspnetcore/fundamentals/localization/make-content-localizable.md
  • aspnetcore/fundamentals/minimal-apis.md

In order to get the release notes sucked into the main release notes article via these INCLUDES, update the date of the release notes article to today ...

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/release-notes/aspnetcore-11.md

- ms.date: 09/14/2026
+ ms.date: 09/22/2026

Comment thread aspnetcore/blazor/forms/validation-advanced.md Outdated
Comment thread aspnetcore/blazor/forms/binding.md Outdated
Comment thread aspnetcore/blazor/forms/validation-advanced.md Outdated
Comment thread aspnetcore/blazor/forms/validation-advanced.md Outdated
Comment thread aspnetcore/blazor/forms/validation-advanced.md Outdated
Comment thread aspnetcore/fundamentals/validation.md Outdated
Comment thread aspnetcore/fundamentals/validation.md Outdated
Comment thread aspnetcore/fundamentals/validation.md Outdated
Comment thread aspnetcore/fundamentals/validation.md Outdated
Comment thread aspnetcore/fundamentals/validation.md Outdated

@guardrex guardrex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wowzers, @oroztocil! 🤩 Quite an amazing set of updates! I ❤️ everything that you've done here, and I'm sure @danroth27 is excited as well to see these improvements and new content going in.

I just have NITs here and there and some grammatical+style suggestions on the diff. For things like the header cross-linking and underscore naming of fields, let's go ahead with what you're doing. If I need to make updates, I'll do them separately with Wade and Tom later.

WRT the new 11.0 "BlazorSample_BlazorWebApp" sample, I'll try to roll in the rest of the 10.0 sample's code examples later. I tend to do that immediately before or after GA.

I'm sure you see the sample cross-link errors on the build, as we chatted about. Yes, I hope Copilot can fix those for you now that my review is done.

A few more things to do here, too ...........

Please update the ms.dates for the following articles to today:

  • aspnetcore/blazor/forms/binding.md
  • aspnetcore/blazor/forms/index.md
  • aspnetcore/fundamentals/localization/make-content-localizable.md
  • aspnetcore/fundamentals/minimal-apis.md

Please update the date of the release notes article to today ...

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/release-notes/aspnetcore-11.md

- ms.date: 09/14/2026
+ ms.date: 09/22/2026

That rebuilds the article and draws those INCLUDES files into it. Otherwise, only the INCLUDES files are updated, and the live Learn site doesn't show the new content.

@guardrex guardrex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to go, unless you have more work to do. Merge when ready, or re-ping me for another review if you need to make more changes.

@oroztocil

Copy link
Copy Markdown
Member Author

@guardrex Thanks for the feedback and the added polish. I took basically all of your proposed changes and closely adapted the rest. Let me know how you want to proceed with the code samples. Inlining them is fine by me.

Do you think we could get this deployed soon? I would love to be able to point testers at the updated docs while they are testing the new features.

@guardrex

guardrex commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

The only code updates would be if you want to replace underscores in the 11.0 samples (Blazor samples repo) that you put up.

Other than that, this is ready to :shipit:. Merge it when you're ready. I'll then take it live after the live branch builds.

@oroztocil
oroztocil merged commit 0547411 into main Sep 22, 2026
5 checks passed
@oroztocil
oroztocil deleted the oroztocil/validation-docs-rework branch September 22, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants