Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory.attr(_, value) support value function #12

Open
ivawzh opened this issue Jul 30, 2020 · 3 comments
Open

Factory.attr(_, value) support value function #12

ivawzh opened this issue Jul 30, 2020 · 3 comments

Comments

@ivawzh
Copy link

ivawzh commented Jul 30, 2020

Hi.

I am trying to use Faker with Factory.attr. Currently, the second argument is limited to T[K] from attr<K extends keyof T>(name: K, value: T[K]).

Would you please make it support value: T[K] | () => T[K]?

@ivawzh ivawzh changed the title Factory.attr(_, vaule) support vaule function Factory.attr(_, vaule) support value function Jul 30, 2020
@ivawzh ivawzh changed the title Factory.attr(_, vaule) support value function Factory.attr(_, value) support value function Jul 30, 2020
@RodolfoSilva
Copy link

Hello @ivawzh, you can use the sequence method to do that:

.sequence('username', (_) => faker.internet.userName());

@ivawzh
Copy link
Author

ivawzh commented Aug 20, 2020

Hi @RodolfoSilva, thanks for the workaround tips.

Meanwhile imho, it'd still be better to have an intuitive API that uses the right names for the right things. sequence is normally referred to a sequential number-embedded generator. value function is better reflecting a stateless attribute value generator.

@RodolfoSilva
Copy link

I agree, something like https://preview.adonisjs.com/guides/database/factories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants