View Code? Open in Web Editor
NEW
🇧🇷 Funções de formatação, conversão e validação para valores, documentos e outras unidades usadas no Brasil. Como CEP, CNPJ, CPF, BRL (R$), datas, números etc.
License: MIT License
TypeScript 99.44%
JavaScript 0.24%
Dockerfile 0.32%
brazilian-values's People
brazilian-values's Issues
This is a kind of disambiguation from a comment in issue #7 .
Provide a parser to convert list formatted value into an Array.
'1, 2, 3 e 4' = > [ '1' , '2' , '3' , '4' ]
'Vitor, Leonardo, Francisco e Fernando Lima' = > [ 'Vitor' , 'Leonardo' , 'Francisco' , 'Fernando Lima' ]
'' = > [ ]
'1' = > [ '1' ]
'1 e 2' = > [ '1' , '2' ]
fiz a PR. Tive um problema com o meu ambiente local, meu node era 8 e o projeto request 12 então criei um amibente no Docker. Posso fazer a PR dele tambem se interresar. Coloquei umas informações no README sobre o docker no branch docker do meu fork
Originally posted by @mandala21 in #28 (comment)
Opa, tudo certinho? Sou um dos criadores da brazilian-utils (https://github.com/brazilian-utils/brazilian-utils ) e eu achei muito interessante o teu projeto.
Queria te convidar para fazer parte da nossa organização e incorporar tuas lib a nossa toolkit, o que você acha disso? Contamos hoje com 5 contribuidores ativos e seria incrível te ter como parte dessa equipe 😄
isDatePattern
seems useless because I've never had a case to use it and even can't think of one.
It can confuse people instead and should be removed from validators. isDate
, which is a real date validator, should be used instead.
The problem
By default the non numeric characters are removed from the string.
I need to pretty print masked phones and CEPs. How can I do it?
Possible solution
Example of possible implementation
formatToCEP ( '15998030' )
//=> '15998-030'
formatToCEP ( '****8030' , { masked : true } )
//=> '****8-030'
formatToPhone ( '11971626799' )
//=> '(11) 9 7162-6799'
formatToPhone ( '*******6799' , { masked : true } )
//=> '(**) * ****-6799'
The new method signature could be as follows:
formatToCEP ( value , { masked = false , mask_digit = '*' } )
formatToPhone ( value , { masked = false , mask_digit = '*' } )
Supporting #22 request is something we can't do, but we can provide a better way to handle it by improving parseToDate
function.
request the merge funcionality isCPF with isCPNJ for validation
É comum encontrar aplicações que usem um único campo como CNPJ ou CPF. E exportar uma função que faça isso automaticamente será bastante útil.
example
1004218907
context.true(isCPF('1004218907'));
isCPF
says this is an invalid CPF
A biblioteca é sobre formatação de documentos, valores e unidades brasileiras, mas o código e a documentação estão em inglês.
A documentação deveria ser em português com a opção do inglês.
What do you think about create a function to format dateTime?
Something like dd/MM/yyyy HH:mm
In isCep function when I verify with this format ##.###-### it will return me a false, but if I use the same value without the mask it will be ok.
So could you use at the cep pattern an optional '.' and '-'
A function to format ArrayLike values into a string using commas and "e" article.
[1, 2, 3, 4] => '1, 2, 3 e 4'
[1, 2] => '1 e 2'
[1] => '1'
[] => ''
In the installation guide, I noticed that it's recommending the installation of the package as a development package.
Since it's a dependency that should be available on production, what about changing it?
Suggested change:
npm install brazilian-values --save-dev
-> npm install brazilian-values --save
Best regards.
You could use value.toLocaleString('pt-br', { style: 'currency', currency: 'BRL' })
.
What do you think about it?
Thanks a lot for this lib 💯
Hi guys, I'm very proud to find a solution so good made by Brazilians.
I'm trying to use the function isPhone
but I don't know if I'm using this wrong, but it's not working as well.
When I type a mobile phone starting with 9 the mask works fine but the state not, and the validation not work because of that. 🤔
See this gif and the code working on SandBox.
https://codesandbox.io/s/shy-surf-4bo20
É bastante comum encontrar fluxos com um único campo que pode ser usado tanto como CNPJ quanto CPF. Por isso é interessante ter uma função que já cheque se o valor é um CPF ou um CNPJ válido
We use numbers like 28.187,289
in Brazil and there's no function to format into this.
There's no examples or docs about CDN usage and would be nice if we have it.
eu resolvi splitando no meu projeto, mas seria legal fazer esse split por aqui talvez, se quiser eu posso contribuir :), valeuee
segue o formato: '2019-11-27T19:00:00Z'
This is a kind of disambiguation from a comment in issue #6 .
Provides a parser to convert brazilian number formatted value into a number.
'1' = > 1
'2.000' = > 2000
'129.034,138' = > 129034.138
Inclui a função de validação de email que ai o pacote fica completo :)
const validaEmail = function (email) {
const re = /^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/
return re.test(email)
}
Ao usar o isCNPJ percebi que mesmo tendo letras junto a um CNPJ válido a validação é feita com sucesso.
ex: 64.637.agsvs009/0001-90 > true
It's me again 😁
I'm trying to use formatToCapitalized
function, but it's impossible to type space-key
as you can see in this example on SandBox below:
https://codesandbox.io/s/keen-bose-k6y63
Thanks for helping 🙏🏼
Muito boa esse lib.
Sugiro uma validação para os telefones também.