Skip to content

Validate: reject phone numbers that fail libphonenumber - #1584

Merged
Baskarayelu merged 5 commits into
Remitwise-Org:mainfrom
1nonlypiece:validate/1470-phone-libphonenumber
Jul 30, 2026
Merged

Validate: reject phone numbers that fail libphonenumber#1584
Baskarayelu merged 5 commits into
Remitwise-Org:mainfrom
1nonlypiece:validate/1470-phone-libphonenumber

Conversation

@1nonlypiece

Copy link
Copy Markdown
Contributor

Summary

The profile settings phone field (components/settings/ProfileSection.tsx) autosaved on every keystroke with no validation at all. Adds isValidProfilePhone() (lib/validation/phone.ts, wrapping libphonenumber-js) and wires it into handlePhoneChange: an invalid number shows an inline role="alert" error and skips triggerSave(); a valid one clears the error and autosaves as before. An empty/whitespace value is treated as valid since the field isn't required. Requires an international (+-prefixed) number since there's no country selector to supply a default region.

Also adds the new settings.profile.phone_invalid translation key to both en.json/es.json -- the settings.* tree is otherwise entirely missing from the locale files (a large pre-existing gap, out of scope to backfill here), but I didn't want to add another broken key on top of it.

Testing

  • node node_modules/vitest/vitest.mjs run ... tests/unit/validation/phone.test.ts tests/unit/settings/ProfileSection.test.tsx -- 8/8 pass (pure validation function edge cases, plus the component showing/clearing the error and not erroring on the valid initial value)
  • npm run test:unit:vitest -- 305 passing (was 297 on main), zero regressions
  • npx eslint on all touched files -- clean
  • npx tsc --noEmit -- no new errors in any touched file

Closes #1470

@Baskarayelu
Baskarayelu merged commit 1d9b4e7 into Remitwise-Org:main Jul 30, 2026
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.

Validate: reject phone numbers that fail libphonenumber

2 participants