[feature-request] Add formatPhone
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
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?
Sure! I'll be working on this on the next days 😀
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?
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.
Sera coberto na proxima versao!