Git Product home page Git Product logo

faker-br's Introduction

Faker-br - Baseado no "faker" para desenvolvimento no Brasil

Build Status

Tamnil Saito Jr. < [email protected] >

Fork baseado no Faker.js para implementação no Brasil em língua portuguesa. Este pacote mantém todas as definições de linguagem do Faker.js V 4.0.x. o idioma principal foi alterado de en para "pt_BR" , e fallback para "en". Portanto a língua nativa do faker-br se torna o português, com fallback para ingles que possui implementaçoes não disponiveis nas outras linguagens As funçoẽs nativas do faker foram mantidas.

Instalacão:

npm install faker-br

Faker-br CLI

para aplicaçoes em linha de comando:

  • sh/bash:
    $ npm install -g faker-br
    $ echo meu cpf é `faker-br br.cpf`
    meu cpf é 65444122529

Inclusão da seguintes funções:

  • gerador de CPF

  • gerador de CNPJ

  • gerador de cartão de crédito válido

  • Aumento nos nomes em português, reduzindo probabilidade de colisão de nomes-sobrenomes, resultantes combinação

  • A fazer:

    • gerador de RG (todo)
    • gerador de CEP (todo)
    • gerador de profissões (todo)

    A geração de cartao de credito no faker.js, gera numeros não validados. O faker-br usa geração de numeros válidos por "Luhn algorithm -Mod 10"

A medida do possível, este módulo respeita a estrutura do faker.js (4.0.x) permitindo a substituição direta:

// original
// const faker = require('faker');

// usando faker-br
const faker = require('faker-br');

Uso

var faker = require('faker-br');
let meuCpf = faker.br.cpf();

As funçoes básicas são do faker 4.1 (https://github.com/Marak/faker.js).

Browser

<script src = "faker-br.js" type = "text/javascript"></script>

Node.js

var faker = require('faker-br');

Aplicação

var randomcpf = faker.br.cpf();
var randomCnpj = faker.br.cnpj();

console.log(faker.br.cnpj()) ;

API

Implementações para pt_BR

API exclusiva para pt_BR

namespace: .br

Namespace exclusivo para campos brasileiros.
  • .br.cpf()

    • opts(Object opcional)
      • format:boolean retorna valor formatado
  • .br.cnpj()

    • opts(Object opcional)
    • format:boolean retorna valor formatado

name

  • adição de mais nomes para pt-br o que aumenta o numero de combinações, reduzindo repetiçoes.
  • adição de campos nao traduzidos para pt_BR marcados como "new", originalmente existentes em inglês.

name.gender name.firstname (extended) (extended: 2756 items, original:91 ) name.male_first_name (new) (extended: 2043 items, original:0 ) name.female_first_name (new) (extended: 713 items,original:0 ) name.name (direct imnport) name.gender (new) name.prefix (new) name.title (translated)

modulos traduzidos

commerce: color,department.product name name: gender prefix

API Methods

faker-br

  • br

    • cpf
    • cnpj
  • address

    • zipCode
    • zipCodeByState
    • zipCodeValid
    • zipCodeValidByState
    • city
    • cityPrefix
    • citySuffix
    • streetName
    • streetAddress
    • streetSuffix
    • streetPrefix
    • secondaryAddress
    • county
    • country
    • countryCode
    • state
    • stateAbbr
    • latitude
    • longitude
  • commerce

    • color
    • department
    • productName
    • price
    • productAdjective
    • productMaterial
    • product
  • company

    • suffixes
    • companyName
    • companySuffix
    • catchPhrase
    • bs
    • catchPhraseAdjective
    • catchPhraseDescriptor
    • catchPhraseNoun
    • bsAdjective
    • bsBuzz
    • bsNoun
  • database

    • column
    • type
    • collation
    • engine
  • date

    • past
    • future
    • between
    • recent
    • soon
    • month
    • weekday
  • fake

  • finance

    • account
    • accountName
    • mask
    • amount
    • transactionType
    • currencyCode
    • currencyName
    • currencySymbol
    • bitcoinAddress
    • ethereumAddress
    • iban
    • bic
  • hacker

    • abbreviation
    • adjective
    • noun
    • verb
    • ingverb
    • phrase
  • helpers

    • randomize
    • slugify
    • replaceSymbolWithNumber
    • replaceSymbols
    • shuffle
    • mustache
    • createCard
    • contextualCard
    • userCard
    • createTransaction
  • image

    • image
    • avatar
    • imageUrl
    • abstract
    • animals
    • business
    • cats
    • city
    • food
    • nightlife
    • fashion
    • people
    • nature
    • sports
    • technics
    • transport
    • dataUri
  • internet

    • avatar
    • email
    • exampleEmail
    • userName
    • protocol
    • url
    • domainName
    • domainSuffix
    • domainWord
    • ip
    • ipv6
    • userAgent
    • color
    • mac
    • password
  • lorem

    • word
    • words
    • sentence
    • slug
    • sentences
    • paragraph
    • paragraphs
    • text
    • lines
  • name

    • firstName
    • lastName
    • findName
    • jobTitle
    • prefix
    • suffix
    • title
    • jobDescriptor
    • jobArea
    • jobType
  • phone

    • phoneNumber
    • phoneNumberFormat
    • phoneFormats
  • random

    • number
    • float
    • arrayElement
    • objectElement
    • uuid
    • boolean
    • word
    • words
    • image
    • locale
    • alphaNumeric
    • hexaDecimal
  • system

    • fileName
    • commonFileName
    • mimeType
    • commonFileType
    • commonFileExt
    • fileType
    • fileExt
    • directoryPath
    • filePath
    • semver

Localization

Individual Localization Packages

By default, requiring faker will include all locale data. In a production environment, you may only want to include the locale data for a specific set of locales.

// loads only de locale
var faker-br = require('faker/locale/de');

Setting a randomness seed

If you want consistent results, you can set your own seed:

faker.seed(123);
us of version `v2.0.0` faker-br has support for multiple localities.

The default language locale is set to English.

Setting a new locale is simple:

```js
// sets locale to de
faker.setLocale("de");
// or
faker.locale = "de";

var firstRandom = faker.random.number();

// Setting the seed again resets the sequence. faker.seed(123);

var secondRandom = faker.random.number();

console.log(firstRandom === secondRandom);


## Tests

    npm install .
    make test

You can view a code coverage report generated in coverage/lcov-report/index.html.

## Building faker-br

faker-br uses [gulp](http://gulpjs.com/) to automate it's build process. Running the following build command will generate new browser builds, documentation, and code examples for the project.

npm run-script build


## Building JSDocs

npm run-script doc



## Maintainer

#### Tamnil Saito Junior <[email protected]>

Faker-br - Copyright (c) 2018
Tamnil Saito Junior

http://github.com/tamnil/faker-br/

Faker-br was forked by and has used data definitions from:
 * http://github.com/marak/faker.js/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-----------------------------------

Permissão é concedida, gratuitamente, a qualquer pessoa que obtiver
uma cópia deste software e dos arquivos de documentação associados
"Software"), para lidar com o Software sem restrições, incluindo
sem limitação os direitos de usar, copiar, modificar, mesclar, publicar,
distribuir, sublicenciar e / ou vender cópias do Software, e para
permitir que pessoas a quem o Software é fornecido façam isso, sujeitas a
as seguintes condições:

O aviso de copyright acima e este aviso de permissão devem ser
incluído em todas as cópias ou partes substanciais do Software.

O SOFTWARE É FORNECIDO "COMO ESTÁ", SEM GARANTIA DE QUALQUER TIPO,
EXPRESSA OU IMPLÍCITA, INCLUINDO, MAS NÃO SE LIMITANDO ÀS GARANTIAS
COMERCIABILIDADE, ADEQUAÇÃO A UM FIM ESPECÍFICO E
NÃO INFRAÇÃO. EM NENHUM CASO, OS AUTORES OU OS TITULARES DOS DIREITOS DE AUTOR
RESPONSÁVEL POR QUALQUER REIVINDICAÇÃO, DANOS OU OUTRAS RESPONSABILIDADES, QUER EM AÇÃO
CONTRATO, DELITO OU DE OUTRA FORMA, DECORRENTE DE, FORA OU EM CONEXÃO
COM O SOFTWARE OU O USO OU OUTRAS OFERTAS NO SOFTWARE.






faker-br's People

Contributors

0xchimz avatar alexpts avatar aleyasen avatar almazn avatar bryandonovan avatar cliffpyles avatar dimitarchristoff avatar dmamills avatar driade avatar ducin avatar fedosov avatar fotoverite avatar hkal avatar jayliu50 avatar josefsalyer avatar kbariotis avatar lolfactor avatar mandulaj avatar marak avatar portse avatar richardbutler avatar robscotts4rb avatar sbmart avatar shadefinale avatar stichoza avatar tamnil avatar titonobre avatar tylerreichle avatar vectart avatar vivekseth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

faker-br's Issues

Tempo de geração de CPF e CNPJ

faker.br.cpf and faker.br.cnpj
returns a big array, but can return results on the fly for better performance and memory .
random values from array are extracted, it can lead to a colison, serial or on the fly generation will work better

Could not find a declaration file for module 'faker-br'. '(pasta do projeto) faker-br/index.js' implicitly has an 'any' type.

Oi!
Estou instalando a sua versão do faker para um projeto aonde preciso gerar cnpj, em cypress!
Na hora da instalação dá tudo certo e cria os arquivo, dentro do package.json está incluindo também.

Porém quando importar o arquivo, tem dado erro:

Could not find a declaration file for module 'faker-br'. 'c:/Users/marin/projects/cypress-direto-do-ponto/node_modules/faker-br/index.js' implicitly has an 'any' type.

Tentei fazer a importação de duas formas:
const faker = require('faker-br');

ou através do import
import { faker } from 'faker-br'
e as duas dá o mesmo erro

Cannot find module 'lodash'

Após instalar o package e tentar executar ele diretamente no bash, é retornado erro de dependência.
Erro foi reproduzido em máquina com SO Windows e Ubuntu

Windows:
npm: 7.11.2
node: 16.1.0

Ubuntu:
npm: 7.18.1
node: 16.4.0

Passos e erro

$ npm i -g faker-br

added 1 package, and audited 2 packages in 3s

found 0 vulnerabilities

$ faker-br br.cpf
node:internal/modules/cjs/loader:930
  throw err;
  ^

Error: Cannot find module 'lodash'
Require stack:
- /home/mesaque/.nvm/versions/node/v16.4.0/lib/node_modules/faker-br/cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
    at Function.Module._load (node:internal/modules/cjs/loader:772:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/home/mesaque/.nvm/versions/node/v16.4.0/lib/node_modules/faker-br/cli.js:11:11)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/mesaque/.nvm/versions/node/v16.4.0/lib/node_modules/faker-br/cli.js'
  ]
}

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.