Mgenerate / template

With mgenerate (or mgeneratejs), is there a way to set a template file to fill a collection string field with only alphabetical characters, only capital letters, or following some kind of arbitrary regular expression?

Hi @Michel_Bouchet

You can use the underlying Chance.js library with mgeneratejs for example:
mgenerate.js '{"letter": { $character: { "pool": "abcde" }}}

The docs page for character in Chance.js here.

Any $ (dollar) field sent to mgeneratejs and not already defined will just be passed to Change.js for further processing so you can build more complex random data using this approach.

Hope this helps.

Kindest regards,

Yes, with a bit of digging and practice, that works indeed. Thanks!

1 Like