Draft
Fix: address validation fires unconditionally when updating name/email on Admin User page#1423
Conversation
- Remove [Required] from Address, City, Country, PostalCode fields in UserPersonalUpdateModel - Implement IValidatableObject with conditional validation: if any address field is provided, all required address fields (Address, City, Country, PostalCode) must be filled - Add HasAnyAddressField() helper method - Fix OnPostUpdatePersonalInfoAsync to only call UpdateShippingAddress when address fields are present - Add validation summary div to Admin/User.cshtml personal info form - Add unit tests for HasAnyAddressField and conditional address validation Closes #1422
Copilot
AI
changed the title
[WIP] Fix address validation when updating user details
Fix: address validation fires unconditionally when updating name/email on Admin User page
Jul 16, 2026
ardalis
approved these changes
Jul 16, 2026
ardalis
approved these changes
Jul 16, 2026
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.
Submitting the Admin User personal info form with only name/email changes fails with
{"InvalidUserId":["Bad Data"],"UserPersonalUpdateModel.Address":["The Address field is required."]}because address fields carry[Required]regardless of intent.Changes
UserPersonalUpdateModel[Required]fromAddress,City,Country,PostalCodeIValidatableObject: address group validation fires only when at least one address field is non-empty; if any is set, all ofAddress/City/Country/PostalCodemust be providedHasAnyAddressField()helper (reused in handler)Admin/User.cshtml.cs—OnPostUpdatePersonalInfoAsyncUpdateShippingAddresscall behindHasAnyAddressField()to avoid null-dereference when no address is submittedAdmin/User.cshtmlasp-validation-summaryto the personal info form so server-side validation errors render on-page instead of as a raw JSONBadRequestTests