Skip to content

fix(core-users): distinguish validation error reasons for email and u…#692

Open
networkinss wants to merge 2 commits intounchainedshop:masterfrom
networkinss:fix/distinguish-validation-error-reasons
Open

fix(core-users): distinguish validation error reasons for email and u…#692
networkinss wants to merge 2 commits intounchainedshop:masterfrom
networkinss:fix/distinguish-validation-error-reasons

Conversation

@networkinss
Copy link

…sername

Default validators returned false for both invalid format and duplicate
entry. Callers threw a single generic error for both, causing the Admin
UI to show a misleading message even when the real problem was a duplicate.

defaultValidateEmail and defaultValidateUsername now return a typed
ValidationResult object instead of a boolean. The four call sites in
configureUsersModule propagate the specific reason as the Error cause:
EMAIL_FORMAT_INVALID, EMAIL_ALREADY_EXISTS, USERNAME_TOO_SHORT,
USERNAME_ALREADY_EXISTS.

errors.ts gains EmailFormatInvalidError and UsernameTooShortError,
and the previously merged messages on EmailAlreadyExistsError and
UsernameAlreadyExistsError are made specific.

…sername

  Default validators returned false for both invalid format and duplicate
  entry. Callers threw a single generic error for both, causing the Admin
  UI to show a misleading message even when the real problem was a duplicate.

  defaultValidateEmail and defaultValidateUsername now return a typed
  ValidationResult object instead of a boolean. The four call sites in
  configureUsersModule propagate the specific reason as the Error cause:
  EMAIL_FORMAT_INVALID, EMAIL_ALREADY_EXISTS, USERNAME_TOO_SHORT,
  USERNAME_ALREADY_EXISTS.

  errors.ts gains EmailFormatInvalidError and UsernameTooShortError,
  and the previously merged messages on EmailAlreadyExistsError and
  UsernameAlreadyExistsError are made specific.
  Return { valid: true } instead of a bare boolean to match the
  ValidationResult type introduced by fix/distinguish-validation-error-reasons.
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.

1 participant