faker icon indicating copy to clipboard operation
faker copied to clipboard

Support inter-field dependencies

Open asilverman opened this issue 5 years ago • 2 comments

Consider the following struct

type Entry struct {
    Bananas []int
    BananasCount int
}

The field BananasCount must be consistent with len(Entry.Bananas)

How can one create this kind of fake instance of Entry using faker?

asilverman avatar Dec 19 '19 21:12 asilverman

I think It's still do-able. But, if it's possible I prefer to make it as a custom faker function that you can register by your self to faker.

I still didn't found this will be very useful to a lot of people. I will keep this issue open, if in the future there's a lot of requesting the same features, we will re-consider to move it as the main function.

How about that?

bxcodec avatar Jan 28 '20 04:01 bxcodec

@bxcodec I have a similar use-case, say FooId and BarId, and would like to generate a random string for either of them but not for both of them at the same time; could you give an example of how could I make a custom faker function for that?

filipegorges avatar Jun 16 '20 19:06 filipegorges