Giter Site home page Giter Site logo

zod-mocking's Introduction

Hi there ๐Ÿ‘‹

zod-mocking's People

Contributors

dependabot[bot] avatar dipasqualew 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

Watchers

 avatar  avatar  avatar

zod-mocking's Issues

How to?

Hi, I understand this is a POC. But I would like to know how to use this package. Cheers.

fix: Support number's positive, negative, nonpositive, nonnegative

At the moment the number mocker fails to take in account the number 0 for minimum and maximum and therefore casts them to MIN_INTEGER and MAX_INTEGER. The number 0 is used for the following modifiers:

  • number().positive()
  • number().negative()
  • number().nonpositive()
  • number().nonnegative()

Additionally, number()._def.minimum.inclusive and number()._def.maximum.inclusive should both be considered when generating the number.

feat: Support transforms

Zod fields can specify transforms functions that are used to cast or transform the validated value.

Mock generators should perform he same transformations.

feat: Overrides support

As a library user, when I generate mocks I'd like to specify mocks for some or all of the fields of my field / model. This is because:

  1. I want more control over the generated mock, or
  2. I want a deterministic value (i.e. a boolean field that is always false) or
  3. My field is very hard to compute (i.e uses refinements).

Specifying an override skip the field generation entirely.

feat: Deterministic pseudorandom values

As a library user, I'd like to be able to specify a seed, or let zod-mocking to use a seed, so that I can produce consistent mock values.

In other words:

  1. mockValid(myField, { seed: 1 }) === mockValid(myField, { seed: 1 });
  2. mockValid(myField, { seed: 1 }) !== mockValid(myField, { seed: 2 });
  3. mockValid(myField, { seed: true }) === mockValid(myField, { seed: 1 });

feat: Export to JSON

As a library user, I may need the mocks I have generated in multiple repositories, and these repositories may need to consume the mocks in other programming languages (i.e. Python, Rust, etc).

It would be helpful to be able to generate the mocks and then export them as JSON objects, so that they can be universally consumed.

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.