How to use the finance function from faker

Find comprehensive JavaScript faker.finance code examples handpicked from public code repositorys.

faker.finance is a module in the Faker library that generates fake financial data.

7
8
9
10
11
12
13
14
15
16
id: faker.random.uuid(),
name: faker.company.companyName(),
contact: faker.phone.phoneNumber(),
address: faker.address.streetAddress(),
tin: faker.finance.iban(),
sss: faker.finance.iban(),
philhealth: faker.finance.iban(),
isDeleted: 0,
// TODO: we need to make sure to match company to the user
createdBy: '48e40a9c-c5e9-4d63-9aba-b77cdf4ca67b',
fork icon141
star icon687
watch icon25

+ 5 other calls in file

11
12
13
14
15
16
17
18
19
20
21
22


const realityCategory = new realityCategory({
    id: faker.random.uuid(),
    name: faker.vehicle.type(),
    realityIds: [],
    cost: faker.finance.amount(20, 100)
})


const realitys = []
const customers = []
fork icon0
star icon1
watch icon0

How does faker.finance work?

faker.finance is a module in the faker.js library that generates various types of finance-related data such as credit card numbers, transaction amounts, and currency codes. When called, the finance module randomly generates and returns fake financial data based on different methods within the module.

53
54
55
56
57
58
59
60
61
62
const createAccount = user => {
   const obj = {
      owner: user.id,
      type: faker.random.arrayElement(['basic', 'premium', 'gold']),
      is_active: faker.random.boolean(),
      sortcode: faker.finance.mask(6, false, false),
      number: faker.finance.mask(8, false, false),
      currency: faker.random.arrayElement(['eur', 'gbp']),
      current_balance: faker.finance.amount(1, 10000, 2)
   };
fork icon0
star icon0
watch icon1

+ 26 other calls in file

275
276
277
278
279
280
281
282
283
284
  return {
    transaction_id: faker.random.uuid(),
    merchant_id: faker.random.uuid(),
    customer_id: faker.random.uuid(),
    amount: faker.random.number({ min: 1, max: 10000 }),
    currency: faker.finance.currencyCode(),
    timestamp: new Date(),
  };
case 'vending-machine':
  return {
fork icon0
star icon0
watch icon0

Ai Example

1
2
3
4
const faker = require("faker");

const cardNumber = faker.finance.creditCardNumber();
console.log(cardNumber); // output: 4539946875106186

9
10
11
12
13
14
15
16
17
18
19


const carCategory = new CarCategory({
    id: faker.datatype.uuid(),
    name: faker.vehicle.type(),
    carIds: [],
    price: faker.finance.amount(20,100)
})
//o resultado do for será salvo nesse array
const cars= []
const customers = []
fork icon0
star icon0
watch icon0

11
12
13
14
15
16
17
18
19
20
21
22


const carCategory = new CarCategory({
    id: faker.random.uuid(),
    name: faker.vehicle.type(),
    carIds: [],
    price: faker.finance.amount(20, 100)
})


const cars = []
const customers = []
fork icon0
star icon0
watch icon0