Skip to content

Commit

Permalink
limit regexp repetitions to max of 5
Browse files Browse the repository at this point in the history
  • Loading branch information
webNeat committed Jun 5, 2018
1 parent 0749149 commit cffc3cc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const string = def('generateString', {}, [T.StringSchema, $.String],
({choices, match, minLength, maxLength}) => {
if (choices)
match = choices.map(escapeStringRegexp).join('|')
if (match)
if (match) {
match.max = 5
return randexp(match)
}
const length = chance.integer({min: minLength, max: maxLength})
return chance.string({length})
}
Expand Down

0 comments on commit cffc3cc

Please sign in to comment.