8000 fix: make an exception for a special phone number by openoms · Pull Request #4799 · GaloyMoney/blink · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: make an exception for a special phone number #4799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/api/src/domain/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export const checkedToPhoneNumber = (value: string): PhoneNumber | ValidationErr

const trimmedValue = value.trim()
const normalizedPhone = trimmedValue.startsWith("+") ? trimmedValue : `+${trimmedValue}`

// Special exception for the specific phone number
if (
normalizedPhone === "+1928282918" ||
normalizedPhone.replace(/\s+/g, "") === "+1928282918"
) {
return normalizedPhone as PhoneNumber
}

const phoneNumber = parsePhoneNumberFromString(normalizedPhone)
if (!phoneNumber?.country) {
return new InvalidPhoneNumber(trimmedValue)
Expand Down
14 changes: 14 additions & 0 deletions core/api/test/unit/domain/users/checked-to-phonenumber.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ describe("phonenumber-check", () => {
phone = checkedToPhoneNumber(" 16505554321 ")
expect(phone).toEqual("+16505554321")
})

it("Accepts the special exception phone number +1928282918", () => {
// This phone number would normally be invalid (only 9 digits after country code)
// but we've added a special exception for it
const phone = checkedToPhoneNumber("+1928282918")
expect(phone).toEqual("+1928282918")

// Also test with spaces and without + prefix
const phoneWithSpaces = checkedToPhoneNumber(" +1 928 282 918 ")
expect(phoneWithSpaces).toEqual("+1 928 282 918")

const phoneWithoutPlus = checkedToPhoneNumber("1928282918")
expect(phoneWithoutPlus).toEqual("+1928282918")
})
})
Loading
0