neomatrixcode / Faker.jl

generator of fake data for julia
https://faker.vercel.app/
MIT License
52 stars 11 forks source link

Allow faking custom types #20

Closed yakir12 closed 3 years ago

yakir12 commented 3 years ago

Users generate custom types that they need to fake.

Exposing a method or two that the user needs to define for her custom type may allow her to fake instances of that type.

Right now it she needs to construct the instance from a combination of the types you already defined.

This is useful when seeding a database for testing/developing.

yakir12 commented 3 years ago

I'm inclined to close this. Here is what I needed to do to define a fake custom user for my specific needs:

fakeuser(id) = User(
                  DbId(id),
                  string(Faker.first_name(), " ", Faker.last_name()),
                  Faker.user_name(),
                  Faker.password(),
                  Faker.email())

I can not see how this can be made simpler than it already is.

I'll leave this to your discretion.

neomatrixcode commented 3 years ago

Currently there is the profile method:

https://github.com/neomatrixcode/Faker.jl/blob/3e684b6e9696d3ec0973b5ee5f81eafdefdde47a/src/persona.jl#L37

internally has a dictionary. However, the method he proposes is more flexible. The function will be added in the next version.

Thank you very much for your contribution.

neomatrixcode commented 3 years ago

Thanks for your contribution, this feature has been added to version 0.3 of Faker, here you will find links with more information.

https://app.gitbook.com/@neomatrixcode/s/faker/guide/providers/person

https://app.gitbook.com/@neomatrixcode/s/faker/guide/generator

yakir12 commented 3 years ago

Wow, looks great!