4 ms·
According to the readme: "Regular expressions are used in every language, every programmer is familiar with them. Regex can be used to easily express complex s
by luiz-pv9 11y ago
According to the readme:
"Regular expressions are used in every language, every programmer is familiar with them. Regex can be used to easily express complex strings. What better way to generate a random string than with a tool you can easily use to express the string any way you want?"
An example where this is useful (I guess) is generating data for tests. You can easily define an email regexp to generate random "valid" values for each model.
- anc84 11y agoBut don't you generate the test input from what your test ends up accepting? I don't see the point.
- usrusr 11y agoThat's true if your validation exists in a vacuum. But if you have a picky black box backend and the input validation you quickly made up allows strings that the backend chokes on, this is the way to validate the validation regex.
- zeroonetwothree 11y agoFor testing you'd want to generate strings non-uniformly, i.e. you want to hit edge cases rather than test 1 billion similar 20 character length e-mails.
- luiz-pv9 11y agoThat's true. What I meant was that this tool is good to support testing the same way factories work: generating random valid emails, phones, addresses, etc., for each record.