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

fake data generation seed #8

Open
matteosister opened this issue Mar 18, 2020 · 2 comments
Open

fake data generation seed #8

matteosister opened this issue Mar 18, 2020 · 2 comments

Comments

@matteosister
Copy link

is there a way to provide the generator with a seed, so that, given the same seed, I will always get the same fake data back?

I'm trying to mock an external web server, and I would like to return fake data based on a provided id.

Many thanks for the great lib!

@nixpulvis
Copy link
Collaborator

This is definitely doable, but I want to rethink the API for this crate a bit in the process...

Hopefully the general Faker interface wont need to change (much?), but I really don't like having Helpers in every structure, and it compounds the problem of passing around a seed everywhere. I don't expect this to be hard however.

Let me give some ideas a try and post an update later. Thanks for bringing this crate back to my attention.

@nixpulvis
Copy link
Collaborator

nixpulvis commented Mar 20, 2020

Well I've fixed the Helpers bit (aka removed them). But there's still a number of problems... Primarily that the Locale is duplicated in many places. This has nothing to do directly with this issue, however I believe I need to fix this first, since it may influence the API.

Both the locale and RNG seed are cases of the same sort of issue, which is state that needs to be set when Faker is created, and shared to the underlying structures. I think I want to leave the sub-structures (e.g. Address, Name, etc) mostly for organizational purposes, though since using them on their own doesn't make a lot of sense to me, perhaps removing them is a change in the API that should be implemented.

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

No branches or pull requests

2 participants