Skip to content

Commit

Permalink
fix : 폰 번호에 dash 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Jul 30, 2024
1 parent 0a68b8d commit 819d0f4
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,21 @@ internal data class GiftPaymentInfoResponse(
reservationState = reservationStatus.toReservationState(),
completedDateTime = null,
visitorName = recipientName,
visitorPhoneNumber = recipientPhoneNumber,
visitorPhoneNumber = recipientPhoneNumber.toDashedPhoneNumber(),
depositorName = senderName,
depositorPhoneNumber = senderPhoneNumber,
depositorPhoneNumber = senderPhoneNumber.toDashedPhoneNumber(),
csReservationId = csReservationId,
cardDetail = cardDetail?.toDomain(),
provider = easyPayDetail?.provider ?: ""
)
}

private fun String.toDashedPhoneNumber(): String {
if (!isPurePhoneNumber) return this

return slice(0..2) + "-" + slice(3..6) + "-" + slice(7..10)
}

private val String.isPurePhoneNumber
get() = "^\\d{11}$".toRegex().matches(this)
}

0 comments on commit 819d0f4

Please sign in to comment.