fixture-monkey icon indicating copy to clipboard operation
fixture-monkey copied to clipboard

Add a new module supports datafaker

Open seongahjo opened this issue 3 years ago • 8 comments

Describe the feature you request

Add a new module supports datafaker

seongahjo avatar Dec 12 '22 10:12 seongahjo

I believe java-faker is no longer maintained. There is an actively maintained forked at https://github.com/datafaker-net/datafaker

@bodiam - maybe somebody from the Data Faker team can help with the integration?

armandino avatar Jan 16 '23 06:01 armandino

Hi there! This library looks interesting, and happy to share some ideas on this.

Is there some api or idea you had in mind?

bodiam avatar Jan 16 '23 06:01 bodiam

@bodiam Hi thank you for your help! We would discuss how to integrate with datafaker in a weekly meeting and share ideas on this issue.

Thank you for your help too, @armandino

seongahjo avatar Jan 17 '23 03:01 seongahjo

@seongahjo no worries. Happy to connect two great libraries.

armandino avatar Jan 17 '23 05:01 armandino

@bodiam Hello, we've discussed how to integrate with datafaker.

Is there any way to make a random value which satisfies condition? For example, we want to make a firstName whose length is 5.

It would be helpful with this feature.

seongahjo avatar Jan 26 '23 11:01 seongahjo

@seongahjo given the nature of the fake values, that would be hard. For example, how would we create a country of 30 characters long? We don't really know the limits even, since they are depending on the Locales.

Yes, it's possible to generate a random string of X characters, but that defeats the purpose of the library.

Can I ask why you'd need such a feature?

bodiam avatar Jan 30 '23 12:01 bodiam

@bodiam We are supporting Jakarta Bean Validation annotations when generating an object.

If a String field has a @Size annotation, the length of field would be a given value.

For example.

class Foo{
   @Size(3)
   String Bar;
}

A length of Bar always be 3.

We'd like to use datafaker to generate a feasible String field value inferred by a property name or other condition. The field might have Jakarta Bean Validation annotations. It would be helpful if datafaker supports filtering by length for an above reason.

seongahjo avatar Jan 31 '23 02:01 seongahjo

It's tricky I think. Some of these fields are populated by regular expressions, or concatenations of different fields.

This might be a silly idea, but how about invoking the faker, potentially several times (100s of times shouldn't be an issue), and record the shortest/longest lengths?

DaraFaker cannot, and will never be able to generate a string of arbitrary length for any propery. For example, a license plate of 25 characters wouldn't make sense, or a full name of 2 characters.

bodiam avatar Jan 31 '23 06:01 bodiam