Ensure Faker::Internet.password
method behavior is consistent with length parameters
#3034
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
When using
Faker::Interner.password
, themin_length
andmax_length
options are not always respected.For instance, running the following snippet will give password out of the desired length range:
This can lead to unexpected behavior when using the
Faker::Internet.password
method.Changes proposed in this pull request
This PR fixes the issue by ensuring that the password generated respects the
min_length
andmax_length
options.mix_case
option from theFaker::Internet.password
method, which is to either force-include an uppercase letter AND a lowercase letter if set totrue
, or to only use lowercase letters if set tofalse
(without enforcing the presence of a letter).digits
inFaker::Internet.password
method #3033Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
If you're proposing a new generator or locale:
[ ] Double-check the existing generators documentation to make sure the new generator you want to add doesn't already exist.[ ] You've reviewed and followed the Contributing guidelines.Closing notes
I'm open to any feedback or suggestions on how to improve this PR if this solution makes sense.
Thanks!