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

[feature-request] Add formatPhone #146

Open
linconkusunoki opened this issue Sep 8, 2020 · 4 comments
Open

[feature-request] Add formatPhone #146

linconkusunoki opened this issue Sep 8, 2020 · 4 comments

Comments

@linconkusunoki
Copy link
Contributor

I think it's a good idea to have the ability to format phones (landline and mobile)

as we already have the validators (isValidMobilePhone and isValidLandlinePhone),
we could also have the formaters (formatMobilePhone and formatLandlinePhone)

or

just have formatPhone that check if it's mobile or landline and apply the correct mask

@hyanmandian
Copy link
Member

Nice idea @linconkusunoki ! I think these functions fit with our scope and we could have formatPhone, formatMobilePhone and formatLandlinePhone. Would you like to do these functions?

@linconkusunoki
Copy link
Contributor Author

Sure! I'll be working on this on the next days 😀

@linconkusunoki
Copy link
Contributor Author

I was thinking about the functions, and I don't know what is the best approach, because there are cases where we'll need to have the country code, so it'll be something like +55 11 98888-7777. Besides that, we can have the parenthesis on the DDD, so a good function could be:

formatPhone(number, { countryCode: 55, withParenthesis: true })

what do you guys think?

@hyanmandian
Copy link
Member

Nice thoughts @linconkusunoki . I think we can do the simple (but scalable) just receiving a phone number and formatting for the most common format in Brazil (51) 99999-9999. If you think that it should be more customizable, maybe receiving a second parameter (like you said) to remove parenthesis or to add country code (we don't need to change our country code because it always the same) can fit well.

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

No branches or pull requests

2 participants