danibram / mocker-data-generator

A simplified way to generate masive mock data based on a schema, you can use the awesome fake/random data generators like (FakerJs, ChanceJs, CasualJs and RandExpJs)
https://danibram.github.io/mocker-data-generator/
MIT License
426 stars 45 forks source link

Question: how to format chance parameters #115

Closed allumbra closed 3 years ago

allumbra commented 3 years ago

In the playground, I tried to use chance: "string({ length: 8, casing: 'upper', alpha: true, numeric: true })" which seems to break (i.e. no output)

This works fine: chance: "string()"

What is the correct way to translate the chance.string call for mocker?

danibram commented 3 years ago

Hi, thank you for using mocker-data-generator As is written in the documentation you have to pass exactly a json syntax, your definition is valid for javascript but is not valid as a JSON, you have examples for integer fn and I assume it works for string too:

{
    chance: 'string({ "length": 8, "casing": "upper", "alpha": true, "numeric": true })'
} 

You can test here: https://danibram.github.io/mocker-data-generator/

Thanks!

danibram commented 3 years ago

I hope this is resolved. So Im going to close that