bchavez / bchavez/Bogus

Use existing value to "seed" another.

Open
#456 3 comments 1 reaction 0 assignees View on GitHub
enhancement future
Dominant language
C#
Stars
9.7k
Forks
538
PR merge metrics
No merged PRs in 30d

Description

### Please describe why you are requesting a feature
Apologies if this exists already, but I'm looking for a way to use Bogus to anonymize data. I would like to anonymize production data for use in a QA environment, but it would be nice if the data came out the same way each time. In other words, I would like to use "Bob Smith" as input and have it come out as "Fred Jones" each time. This is only an example, I don't literally mean those specific names, but it would be helpful for QA if the anonymized data were stable so that when we refresh the data, the example person they were looking at last week still has the same name.

tl;dr - I would like a way to pass a "seed" value to individual rules to ensure that the same random value is generated each time, based on an input value so that, for example, using "Bob" as the seed value always results in "Fred" being generated.

### Please provide a code example of what you are trying to achieve

Something like this:
```csharp
var testUsers = new Faker()
.RuleFor(u => u.FirstName, (f, u) => f.Name.FirstName(u.Gender, seed = {Some string value}))
```

Ideally, "Some value" would be automatically derived from an input value based on the real-world data, such as the existing record's FirstName property.

### Please answer any or all of the questions below

* Is the feature something that currently cannot be done?
Not that I have found in the examples, but I could be simply missing something.

* What alternatives have you considered?
Seeding the generator with the .UseSeed method on each loop through the anonymizer, based on hashing the record's Id. As pointed out in https://github.com/bchavez/Bogus/issues/104 though, any changes made to the structure such as the addition of new fields would throw everything after that off.

* Is this feature request any issues or current problems?

* Has the feature been requested in the past?
Not that I could find in a cursory search of other requests. The closest I've found is https://github.com/bchavez/Bogus/issues/104

**If the feature request is approved, would you be willing to submit a PR?**

No
I wish I had the time, but I don't. Maybe if I get to retire from the day job someday.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing UseSeed behavior and the RuleFor/Name.FirstName usage in the example, then compare the concern with issue #104. Done would mean a defined way to derive a stable per-rule generated value from an input seed, with behavior that remains stable when additional fields are added.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.