faker icon indicating copy to clipboard operation
faker copied to clipboard

Ensuring Unique Values

Open mpchadwick opened this issue 6 years ago • 2 comments

Currently there's no way to ensure unique values:

https://github.com/stympy/faker#ensuring-unique-values

Use case for me is in this project:

https://github.com/mpchadwick/dbanon

I generate random email addresses, but I need to ensure they're unique to prevent a duplicate key issue.

mpchadwick avatar May 24 '19 21:05 mpchadwick

A unique modifier would be an awesome addition.

System-Glitch avatar Oct 09 '19 14:10 System-Glitch

You could always just use faker.Seed() to pick some seed that has unique values for the scope of your usage. For example, if you only ever need 10,000 email addresses, you can find a seed that generates 10,000 unique email addresses and use that for your tests. Just faker.Seed(0) should work fine since the chance of a duplicate is pretty low.

nathanfranke avatar Sep 01 '21 07:09 nathanfranke