# yup-faker

> git@github.com:mauricedb/yup-faker.git

Latest version **0.1.0** (published 2021-01-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install yup-faker
pnpm add yup-faker
yarn add yup-faker
bun add yup-faker
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-01-12 |
| First published | 2020-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 71.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Maurice de Beijer |
| Maintainers | mauricedb |
| Keywords | yup, faker, mocks, testing |

## Links

- npm: https://www.npmjs.com/package/yup-faker
- Repository: https://github.com/mauricedb/yup-faker
- Homepage: https://github.com/mauricedb/yup-faker#readme
- Issues: https://github.com/mauricedb/yup-faker/issues
- npm.io page: https://npm.io/package/yup-faker

## Dependencies (1)

- [faker](https://npm.io/package/faker.md) ^5.1.0

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@farm.js/msw](https://npm.io/package/@farm.js/msw.md) — 0 weekly downloads
- [@diister/valibot-mock](https://npm.io/package/@diister/valibot-mock.md) — 0 weekly downloads
- [mock-api-studio-cli](https://npm.io/package/mock-api-studio-cli.md) — 0 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2021-01-12
- 0.0.2 — 2020-09-02

## README

# yup-faker

Yup schema with fake data generation

## Install

```sh
npm install yup-faker --save-dev
```

## Usage

Create a fake person object that conforms to the specified [Yup](https://www.npmjs.com/package/yup) schema. The data is generated using [Faker](https://www.npmjs.com/package/faker). You do not need to install Faker, it is internal to this package.

The typical, and main, use case of this package is to generate data structures for unit tests. Another use case is generating random sample data in a demo verion of your application.

```ts
import * as yup from 'yup';
import { getFakeData } from 'yup-faker';

const personSchema = yup.object({
  firstName: yup.string(),
  lastName: yup.string(),
  gender: yup.mixed().oneOf(['male', 'female', 'other'] as const),
  email: yup.string().email(),
  birthDate: yup
    .date()
    .min(new Date(1950, 0, 1))
    .max(new Date()),
});

const fakePerson = getFakeData(personSchema);

console.log(JSON.stringify(fakePerson, null, 2));
```

Note:

- The `firstName` and `lastName` will be generated using the `faker.name.firstName()` and `faker.name.lastName()` functions.
- The `gender` will always be one of the three allowed values `male`, `female` or `other`.
- The `email` field will be a valid email.
- The fake `birthDate` generated will always match the required data range of January 1st 1950 to today.

---
_Source: https://npm.io/package/yup-faker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
