Skip to content

Commit

Permalink
fix: format mobile no
Browse files Browse the repository at this point in the history
  • Loading branch information
wanlingt committed Oct 18, 2023
1 parent ef23a72 commit 1507ffc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/modules/sgid/sgid.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SGID_MYINFO_NRIC_NUMBER_SCOPE,
SGIDScope as ExternalAttr,
} from './sgid.constants'
import { formatAddress, formatVehicles } from './sgid.format'
import { formatAddress, formatMobileNo, formatVehicles } from './sgid.format'
import { SGIDScopeToValue } from './sgid.types'

const logger = createLoggerWithLabel(module)
Expand Down Expand Up @@ -166,6 +166,8 @@ export class SGIDMyInfoData
return formatAddress(fieldValue)
case ExternalAttr.VehicleNo:
return formatVehicles(fieldValue)
case ExternalAttr.MobileNoWithCountryCode:
return formatMobileNo(fieldValue)
default:
// SGID returns NA if they do not have the value. We want to return an empty string instead,
// so that this can be processed by our frontend in the same way as Singpass MyInfo
Expand Down
11 changes: 11 additions & 0 deletions src/app/modules/sgid/sgid.format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ export const formatVehicles = (vehicles: string): string => {
return ''
}
}

/**
* Formats SGID MyInfo mobile number field by removing any white space
* @param mobileno
* @example '+65 88889999'
* @returns Whitespace is removed, for example '+6588889999'
*/
export const formatMobileNo = (mobileno: string): string => {
const formattedMobileNo = mobileno.replace(/(\s)+/g, '')
return formattedMobileNo
}

0 comments on commit 1507ffc

Please sign in to comment.