Install with npm:
npm install workie
Install with yarn:
yarn add workie
- Input type number.
- Call formatCpfCnpj(number).
- *Cannot contain special characters, only numbers.
- Input type number.
- Call formatPhone(number).
- *Cannot contain special characters, only numbers.
- Input type number.
- Call formatCep(number).
- *Cannot contain special characters, only numbers.
Cep search module use the cep-promise
wich is multiprovider, the lib will resolve the Promise with the provider wich reply faster.
import {consultaCep} from 'workie'
consultaCep('93315400')
.then(console.log)
// {
// "cep": "93315400",
// "state": "RS",
// "city": "Novo Hamburgo",
// "street": "Rua Visconde de Ouro Preto",
// "neighborhood": "Operário",
// }
In this case will return a "service_error"
, the lib will only reject the Promise when all the providers reply negative.
import {consultaCep} from 'workie'
consultaCep('99999999')
.catch(console.log)
// {
// name: 'CepPromiseError',
// message: 'Todos os serviços de CEP retornaram erro.',
// type: 'service_error',
// errors: [{
// message: 'CEP NAO ENCONTRADO',
// service: 'correios'
// }, {
// message: 'CEP não encontrado na base do ViaCEP.',
// service: 'viacep'
// }]
// }
In this case will return a "validation_error"
, the lib will immediately reject the Promise, without call a provider.
import {consultaCep} from 'workie'
consultaCep('123456789123456789')
.catch(console.log)
// {
// name: 'CepPromiseError',
// message: 'CEP deve conter exatamente 8 caracteres.',
// type: 'validation_error',
// errors: [{
// message: 'CEP informado possui mais do que 8 caracteres.',
// service: 'cep_validation'
// }]
// }
"cep-promise": "^3.0.9"
MIT © Guilherme Maier Knewitz