Skip to content

Faker is a lua library that generates fake data for you.

Notifications You must be signed in to change notification settings

hector-vido/lua-faker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Faker

Faker is a lua library that generates fake data for you.

Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you. Faker is heavily inspired by PHP Faker, Perl Faker, Ruby Faker and by Python Faker.

Actually there is only en_US and pt_BR locales.

Example

The default locale is en_US. Every function that uses a lazy initialization need to be called with ::

local Faker = require('faker')

local faker = Faker:new()
for i = 1, 10 do
        print(faker.randstring())
        print(faker.randint(10))
        print(faker:name())
        print(faker:email())
        print(faker:country())
        print(faker:state())
        print(faker:city())
        print(faker.ssn())
end

-- bbfchjdhaa
-- 1314612416
-- Paul Simmon
-- [email protected]
-- Pitcairn
-- Vermont
-- Locustdale
-- 983-77-4987

Pay attention because faker.ssn only exists when en_US is loaded.

Change Locale

To change locale, simply pass a table on constructor new with this option:

local Faker = require('faker')

local faker = Faker:new({locale = 'pt_BR'})
for i = 1, 10 do
	print(faker:name())
	print(faker:email())
	print(faker.cpf())
	print(faker.cep())
end

-- Maria da Silva
-- [email protected]
-- 744.524.429-86
-- 95194-526

Pay attention because faker.cpf and faker.cep only existis when pt_BR is loaded.

About

Faker is a lua library that generates fake data for you.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages