Closed nirzaf closed 7 months ago
Hi @nirzaf!
This is easily achievable using any of the Replace
methods, so this proposal would unnecessarily bloat the API IMO.
Is there anything that you are missing from the current API?
Hi. Thank you for the feedback.
I think @ChristoWolf is right on this one for the moment. You'll need to create a custom extension method for this if you want better API ergonomics. If there's enough demand for this new method to be in the Bogus API, then we'll consider it in the future; but for now, your best advice is to create a custom extension method; or use the Random.Replace*()
methods as shown below:
void Main()
{
var f = new Faker();
f.Random.ReplaceNumbers(new string('#', 25)).Dump();
f.Random.NumberOnlyString(25).Dump();;
}
public static class MyCustomExtensions
{
public static string NumberOnlyString(this Randomizer r, int length)
{
return r.ReplaceNumbers(new string('#', length));
}
}
//OUTPUT:
9618188693116119676746702
3035736940236164577423885
Method to return a numbers-only string with a specific length defined via parameter