Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable digits in Faker::Internet.password method #3033

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

francktrouillez
Copy link

@francktrouillez francktrouillez commented Dec 6, 2024

Motivation / Background

Currently, a digit is always added to the string generated by Faker::Interner.password. There's currently no way to disable this behavior.

Also, with the current behavior, running Faker::Internet.password(min_length: 2, max_length: 2, mix_case: true) will return a password of length 3, as a digit is always added to the string, in addition to the uppercase and lowercase letters.

Changes proposed in this pull request

This PR allows to disable the use of digits (and the auto-addition of one) when generating passwords. By default, a digit is added, but this can be disabled by setting the digits option to false. Also, when the digits option is set to true (current and default behavior), the required length of the password is updated to reflect the presence of the digit.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • Tests and Rubocop are passing before submitting your proposed changes.

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 idea makes sense.

Thank you very much!

This change allows to allow or not digits inside the password. If `digits: true`, a digit is automatically added.
@francktrouillez francktrouillez force-pushed the feature/allow-to-enable-disable-digits-in-faker-internet-password branch from 2313e3f to 17967e3 Compare December 6, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant