Validate aliases, addresses and phone numbers in the send menu #176

Merged
kamikazechaser merged 14 commits from alias-address-validation into master 2024-11-26 07:24:57 +01:00
Member
  • Update the phone number regex
  • Check whether the recipient is a valid phone number, alias or address
- Update the phone number regex - Check whether the recipient is a valid phone number, alias or address
Alfred-mk added 1 commit 2024-11-20 14:16:08 +01:00
Alfred-mk changed title from updated the regex to match all Kenyan numbers to WIP: updated the regex to match all Kenyan numbers 2024-11-20 14:16:17 +01:00
Alfred-mk added 5 commits 2024-11-20 16:37:45 +01:00
Alfred-mk changed title from WIP: updated the regex to match all Kenyan numbers to WIP: Validate aliases, addresses and phone numbers in the send menu 2024-11-20 16:38:31 +01:00
Alfred-mk added 1 commit 2024-11-20 16:45:45 +01:00
Alfred-mk added 1 commit 2024-11-20 16:56:04 +01:00
Alfred-mk changed title from WIP: Validate aliases, addresses and phone numbers in the send menu to Validate aliases, addresses and phone numbers in the send menu 2024-11-20 17:02:42 +01:00
Alfred-mk requested review from lash 2024-11-20 18:03:57 +01:00
lash requested changes 2024-11-22 02:16:34 +01:00
@ -0,0 +7,4 @@
// Define the regex patterns as constants
const (
phoneRegex = `^(?:\+254|254|0)?((?:7[0-9]{8})|(?:1[01][0-9]{7}))$`
Owner

I think phone regex should be check formatting but not specifics; that is, country code should be filtered elsewhere.

I think phone regex should be check formatting but not specifics; that is, country code should be filtered elsewhere.
@ -0,0 +9,4 @@
const (
phoneRegex = `^(?:\+254|254|0)?((?:7[0-9]{8})|(?:1[01][0-9]{7}))$`
addressRegex = `^0x[a-fA-F0-9]{40}$`
aliasRegex = `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+$`
Owner

alias is same format as email? May want to have a look at https://emailregex.com/

alias is same format as email? May want to have a look at https://emailregex.com/
Author
Member

No, it is not. This is the format that I picked from Sarafu's website

Your shortcode is a unique identifier that can be used by others to send you vouchers. It must be in the following format name@area

No, it is not. This is the format that I picked from Sarafu's website `Your shortcode is a unique identifier that can be used by others to send you vouchers. It must be in the following format name@area`
@Alfred-mk See https://github.com/grassrootseconomics/sarafu.network/issues/174 for Alias requirements
kamikazechaser marked this conversation as resolved
@ -916,2 +908,4 @@
recipient := string(input)
if recipient != "0" {
Owner

when is recipient "0" ?

when is recipient "0" ?
Author
Member

This is related to #126 (comment)

This is related to https://git.grassecon.net/urdt/ussd/pulls/126#issuecomment-2709
Alfred-mk added 1 commit 2024-11-24 14:48:27 +01:00
Alfred-mk added 2 commits 2024-11-25 10:00:00 +01:00
kamikazechaser reviewed 2024-11-25 11:30:57 +01:00
@ -0,0 +49,4 @@
}
// FormatPhoneNumber formats a Kenyan phone number to "254xxxxxxxx".
func FormatPhoneNumber(phone string) (string, error) {

It should be + prefixed. Why? That is how we save it in our common db (graph) and also how most, if not all, API providers expect the phone number.

It should be + prefixed. Why? That is how we save it in our common db (graph) and also how most, if not all, API providers expect the phone number.
Author
Member

Thanks, this has been updated

Thanks, this has been updated
kamikazechaser marked this conversation as resolved
Alfred-mk added 1 commit 2024-11-25 12:37:47 +01:00
Alfred-mk added 1 commit 2024-11-25 13:02:37 +01:00
Alfred-mk added 1 commit 2024-11-26 07:16:26 +01:00
kamikazechaser merged commit 08ff1056d7 into master 2024-11-26 07:24:57 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: urdt/ussd#176
No description provided.