java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

lorem().characters() method sometimes does not include digit.

Open swaroop-tata opened this issue 2 years ago • 4 comments

Describe the bug lorem().characters() method sometimes does not include digit.

To Reproduce Run "lorem().characters(7,true,true)" this in a loop. Observe that some times, the generated string will miss digit.

Expected behavior A digit must include every time when includeDigit is used.

Versions:

  • OS: Windows
  • JDK 11
  • Faker Version 1.0.2

Additional context

swaroop-tata avatar Jun 09 '23 17:06 swaroop-tata

You'd best use https://github.com/datafaker-net/datafake instead, which is an active fork of this library.

bodiam avatar Jun 09 '23 23:06 bodiam

I don't think this is a bug though, it's an option to include numbers. Not always they will be included. If you want to force numbers, you can use something like bothify, regexify, or examplify.

bodiam avatar Jun 09 '23 23:06 bodiam

Thank you for the response.

swaroop-tata avatar Jun 13 '23 13:06 swaroop-tata

In datafaker there is a special Text provider where it's possible to specify minimum number of occurrencies per symbol. I guess, even more it's possible to specify other symbols e.g. from non English abc, it will satisfy your case. For more details https://github.com/datafaker-net/datafaker/blob/main/src/test/java/net/datafaker/providers/base/TextTest.java

snuyanzin avatar Jul 25 '23 06:07 snuyanzin