Skip to content
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

Bugfix / Argentinian transformRule mismatch $2 15-$3-$4 #76

Merged
merged 3 commits into from
Nov 10, 2024

Conversation

DenisDoc
Copy link
Contributor

@DenisDoc DenisDoc commented Nov 8, 2024

Hello, I found a bug while using phone_form_field: ^9.1.0 while trying to input an Argentinian phone number:
Screenshot 2024-11-08 at 18 40 54

I've got the same result with running phone_numbers_parser locally:
Screenshot 2024-11-08 at 22 37 34

I have also checked libphonenumber and it seems to woks fine:
Screenshot 2024-11-08 at 23 48 32

The thing is that the transformRule starts with $2 (ex: $2 15-$3-$4) that will stop the loop and return the string without formatting it properly. I removed the contain index check of the transform rule in order to support the rules that does not start necessarily with 1, and it seems to work fine. If there is a better solution for this problem let me know an i can look into it and update the pr, thanks. Cheers!

Screenshot 2024-11-08 at 23 57 21

…port the rules that does not start with 1. ex: $2 15-$3-$4
@cedvdb
Copy link
Owner

cedvdb commented Nov 8, 2024

Thanks. Please add a test that was failing before and works with the PR

… start with \$1. example: (\$2 15-\$3-\$4)(AR), Argentina
@DenisDoc
Copy link
Contributor Author

DenisDoc commented Nov 9, 2024

Thanks. Please add a test that was failing before and works with the PR

I added the test, please have a look and give it a try.

group(
'format national phone number if transformRule does not start with \$1. example: (\$2 15-\$3-\$4)(AR)',
() {
test('should return the formated phone number not the transformRule string',
Copy link
Owner

@cedvdb cedvdb Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the test, can you rename

should return the formated phone number not the transformRule string

to

=> should format argentinian phone numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Done.

@cedvdb cedvdb merged commit 16e6c97 into cedvdb:main Nov 10, 2024
1 check passed
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.

2 participants