fix: use DataAnnotationsValidator on the Setup form (#47)#69
Merged
Conversation
Port the form-validation fix from the marten-identity login pages (marten-identity#63, "Fix static-SSR form validation"): replace the Radzen validators with <DataAnnotationsValidator /> + <ValidationMessage>, driven by the InputModel's data annotations — matching the Register page. The InputModel already carries [Required], [EmailAddress], [StringLength(MinimumLength = 12)], and [Compare], so validation behaviour is preserved (and the 12-char minimum still enforced), but now works reliably. This replaces the dynamic RadzenLengthValidator length with the static annotation, so the IdentityOptions injection and MinPasswordLength are removed. Closes #47
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.
Closes #47.
What
Ports the form-validation fix already applied to the marten-identity login pages (
marten-identity#63— "Fix static-SSR form validation") toSetup.razor: the Radzen validators (RadzenRequiredValidator,RadzenEmailValidator,RadzenLengthValidator,RadzenCompareValidator) are replaced with a single<DataAnnotationsValidator />plus per-field<ValidationMessage>, driven by theInputModel's data annotations. This matches theRegisterpage (the email + password + confirm analog).Why
The Radzen-validator pattern exhibited the same validation bug fixed in the identity login pages. The
DataAnnotationsValidator+ValidationMessageapproach validates reliably via the form'sEditContext.Behaviour preserved
The
InputModelalready carries[Required],[EmailAddress],[StringLength(100, MinimumLength = 12)], and[Compare], so all rules — including the 12-character minimum (from #59) — still apply and gate submission; error messages still render.One deliberate change: the password length is now validated by the static
[StringLength(MinimumLength = 12)]annotation rather than the dynamicRadzenLengthValidator Min="@IdentityOptions…RequiredLength". This matches the login pages, so the (now unused)IOptions<IdentityOptions>injection andMinPasswordLengthhelper are removed. Server-side enforcement viaUserManageris unchanged; if a host overridesPasswordOptions.RequiredLengthbelow/above 12, the Setup page shows 12 (same as the identity Register page) — a UX detail, not an enforcement gap.Verification
dotnet build -c Release— 0 errors, 0 warnings.dotnet test -c Release— 87/87 (no Setup test exists to change; unchanged elsewhere).