Git Product home page Git Product logo

vitorluizc / brazilian-values Goto Github PK

View Code? Open in Web Editor NEW
529.0 13.0 40.0 1.9 MB

🇧🇷 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%
formatters brazilian brazilian-portuguese validators cnpj-validator cpf-validator cpf-validador cnpj cpj cep

brazilian-values's Issues

Email

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)
}

Telefones

Muito boa esse lib.
Sugiro uma validação para os telefones também.

Include a new format of cep

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 '-'

Documentação em português

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.

Adicionar um ambiente docker para contribuidores

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)

create a parser from list [x, y, z]

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']

formatToDateTime

What do you think about create a function to format dateTime?
Something like dd/MM/yyyy HH:mm

Fix README installation instruction

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.

Prettify masked values [HELP NEEDED] [FEATURE REQUEST]

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 = '*' })

`isDatePattern` should be removed

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.

parser from brazilian number formatted value

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

isPhone not working?

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.

phone

https://codesandbox.io/s/shy-surf-4bo20

Junção de projetos

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 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.