castlemock icon indicating copy to clipboard operation
castlemock copied to clipboard

Help Generating Random Alphanumeric

Open kierangirvan opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. In order to simulate the response of an underlying application I need to generate a random alphanumeric 10 digit value, uppercased.

Describe the solution you'd like Either with the use of faker or an already supported expression, to generate a 10 digit uppercased alphanumeric value. Obviously the 10 digits doesn't need to be fixed e.g. ${RANDOM_ALPHANUMERIC(10)} or along those lines.

Describe alternatives you've considered I've tried to achieve this with faker but struggling to find a solution here also.

Additional context Example output would be 9NP8EOC6DA

kierangirvan avatar Mar 11 '22 13:03 kierangirvan

Hi, @kierangirvan! Try ${FAKER(api="finance().bic().substring(0,10)")}.

If you need one more specific rule, try ${FAKER(api="regexify('([A-Z]){4}([A-Z]){2}([0-9A-Z]){2}([0-9A-Z]{3})?')")}, passing the rule in the regex expression. For example, https://github.com/DiUS/java-faker/blob/master/src/main/java/com/github/javafaker/Finance.java#L54

tobiasrdm avatar Mar 22 '22 13:03 tobiasrdm