ngneat / falso

All the Fake Data for All Your Real Needs 🙂

Home Page:https://ngneat.github.io/falso/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Control character length of individual random values

vgjenks opened this issue · comments

Description

Cannot control length of randomly-generated value, which causes database insert errors where field length matters.

Proposed solution

If I want a randJobTitle() for example - it'd be nice if I could pass an option to limit the results by character length. I'm not talking about a simple substring, but rather, only return values that are of that length or less.

randJobTitle({ size: 50 }) - returns a random job title that is of 50 characters or less. The value "Senior Operational Administrative Assistant - Marketing" would not be selected but "Developer" would be. I'm making these values up of course, to illustrate. This would prevent an insert error if the field was varchar(50).

randJobTitle({ size: 50, length: 10 }) - would do the same, but would be an array of those w/ 50 characters or less.

Alternatives considered

No response

Do you want to create a pull request?

No

I would like to work on this issue !! if u can, can I do this?

But it's already have a PR - #316

Oh!
I thought only email can be sized because the example of email is written!
I misunderstood.
That's great!🚀

Merged in #316 as maxCharCount