Skip to content

fix: use DataAnnotationsValidator on the Setup form (#47)#69

Merged
andregoepel merged 1 commit into
mainfrom
bugfix/setup-form-validation
Jul 5, 2026
Merged

fix: use DataAnnotationsValidator on the Setup form (#47)#69
andregoepel merged 1 commit into
mainfrom
bugfix/setup-form-validation

Conversation

@andregoepel

Copy link
Copy Markdown
Owner

Closes #47.

What

Ports the form-validation fix already applied to the marten-identity login pages (marten-identity#63 — "Fix static-SSR form validation") to Setup.razor: the Radzen validators (RadzenRequiredValidator, RadzenEmailValidator, RadzenLengthValidator, RadzenCompareValidator) are replaced with a single <DataAnnotationsValidator /> plus per-field <ValidationMessage>, driven by the InputModel's data annotations. This matches the Register page (the email + password + confirm analog).

Why

The Radzen-validator pattern exhibited the same validation bug fixed in the identity login pages. The DataAnnotationsValidator + ValidationMessage approach validates reliably via the form's EditContext.

Behaviour preserved

The InputModel already 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 dynamic RadzenLengthValidator Min="@IdentityOptions…RequiredLength". This matches the login pages, so the (now unused) IOptions<IdentityOptions> injection and MinPasswordLength helper are removed. Server-side enforcement via UserManager is unchanged; if a host overrides PasswordOptions.RequiredLength below/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).

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
@andregoepel
andregoepel merged commit e5316c9 into main Jul 5, 2026
3 checks passed
@andregoepel
andregoepel deleted the bugfix/setup-form-validation branch July 5, 2026 07:31
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.

Apply login-page validation fix to Setup page

1 participant