Add .NET 10/11 validation samples and align FieldCssClassProvider style - #662
Draft
oroztocil wants to merge 1 commit into
Draft
Add .NET 10/11 validation samples and align FieldCssClassProvider style#662oroztocil wants to merge 1 commit into
oroztocil wants to merge 1 commit into
Conversation
Adds two sample projects that back code references in the Blazor forms validation articles, and aligns three existing provider samples with the style used across the validation docs. New: 10.0/BlazorWebAppRemoteValidation A three-project solution for the remote validation walkthrough: * BlazorSample: server project with the server form validator and the proxy endpoint. * BlazorSample.Client: model, validation abstraction, client form validator, CustomValidation component, and the Starship10 form. * MinimalApiJwt: the remote validation endpoint. New: 11.0/BlazorSample_BlazorWebApp Covers validation features introduced in .NET 11: * StartsWithAttribute: a custom validation attribute that also supplies a client-side rule for static SSR forms. * A JavaScript initializer that registers the matching client validator. * UsernameUniquenessValidator: asynchronous validation registered both for the whole form and per field. * AsyncValidation page: displays pending and faulted validation state. Changed: CustomFieldClassProvider and CustomFieldClassProvider2 (8.0, 9.0, 10.0) The three provider samples form a progression, so they now share one shape, which makes the difference between them the only thing that varies. Verification Both solutions build with no errors or warnings. The remote validation endpoint was exercised for a valid model, a business-rule failure, and data annotations failures. The .NET 11 static SSR form was checked to confirm the client validation metadata, including the custom rule, and that both the per-form and global opt-outs suppress it while server-side validation continues to run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 608096b5-db3e-4006-adaa-b4da0309ff87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two sample projects that back code references in the Blazor forms validation articles, and aligns three existing provider samples with the style used across those articles.
New:
10.0/BlazorWebAppRemoteValidationA three-project solution for the remote validation walkthrough, which previously carried all of its code inline in the article:
BlazorSampleBlazorSample.ClientCustomValidationcomponent,Starship10formMinimalApiJwtThe layout and namespaces match what the article instructs readers to create, so the code in the sample is the code in the walkthrough.
This also fills a gap:
Starship1throughStarship14were already samples exceptStarship10, which was the only form in the article family that was inlined.New:
11.0/BlazorSample_BlazorWebAppCovers the validation features introduced in .NET 11:
StartsWithAttribute- a custom validation attribute that also supplies a client-side rule for static SSR forms.wwwroot/BlazorSample.lib.module.js- a JavaScript initializer that registers the matching client-side validator.UsernameUniquenessValidator- asynchronous validation registered both for the whole form and per field.AsyncValidationpage - displays pending and faulted validation state.Changed:
CustomFieldClassProviderandCustomFieldClassProvider2(8.0, 9.0, 10.0)The three provider samples form a progression: style all fields, style one field, then apply Blazor's default classes to the rest. They previously used three different shapes for the same concept, which made incidental style the most visible difference between them. They now share one shape, so the only thing that varies is the behavior being demonstrated.
CustomFieldClassProvider3already used this shape and is unchanged.Verification
Both solutions build with no errors and no warnings.
The remote validation endpoint was exercised end to end with authentication mocked out:
204 No ContentDefenseship with no description400with the business-rule error400with both field errorsThe third case confirms
AddValidationruns and validates data annotations before the handler.The .NET 11 static SSR form was rendered and checked to confirm:
Notes
MinimalApiJwt..Clientproject needs aMicrosoft.Extensions.Httppackage reference for the typedHttpClientregistration used by the walkthrough.