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

[1673] Ensure mix_case returns at least one lower and one upper case … #1694

Merged
merged 1 commit into from
Aug 27, 2019

Conversation

bpleslie
Copy link
Member

@bpleslie bpleslie commented Aug 19, 2019

…letter

Resolves Issue #1673

Description:

In order to ensure that at least one lowercase and one uppercase letter was returned when passing mix_case: true to Internet.password, I did the following:

  • Allow Alphanumeric.alphanumeric to accept min_alpha and min_numeric params. (Note: min_numeric is not used, but seemed equally helpful for certain situations. I'm happy to remove it if desired.)
  • Implemented min_alpha in Internet.password altered the mix_case condition to ensure we always return at least one uppercase and one lowercase letter if mix_case is true.

@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch 3 times, most recently from 6a329d6 to db77d36 Compare August 19, 2019 22:15
Copy link
Contributor

@Zeragamba Zeragamba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look good to me, and adding both min_alpha and min_numaric makes sense to me.

lib/faker/default/alphanumeric.rb Outdated Show resolved Hide resolved
lib/faker/default/alphanumeric.rb Outdated Show resolved Hide resolved
@Zeragamba
Copy link
Contributor

Oh, and docs need to be updated.

If possible it would be nice if you could include Yard style docs since that's in the pipeline, but not required.

@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch from db77d36 to cac7ab8 Compare August 20, 2019 02:37
lib/faker/default/alphanumeric.rb Outdated Show resolved Hide resolved
lib/faker/default/alphanumeric.rb Outdated Show resolved Hide resolved
lib/faker/default/alphanumeric.rb Outdated Show resolved Hide resolved
@bpleslie
Copy link
Member Author

Working on the docs now 👍

@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch 4 times, most recently from ff690bb to 2a7af9f Compare August 20, 2019 19:55
@@ -4,7 +4,8 @@ module Faker
class Alphanumeric < Base
class << self
ALPHABET = ('a'..'z').to_a
ALPHANUMS = ALPHABET + (0..9).to_a
NUMBERS = (0..9).to_a
ALPHANUMS = ALPHABET + NUMBERS
Copy link
Member

@vbrazo vbrazo Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be redefining/duplicating this constant since Faker::Base already uses something similar. Check this out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vbrazo good call. I updated to use the constants from the base class.

Faker::Lorem.characters #=> "uw1ep04lhs0c4d931n1jmrspprf5wrj85fefue0y7y6m56b6omquh7br7dhqijwlawejpl765nb1716idmp3xnfo85v349pzy2o9rir23y2qhflwr71c1585fnynguiphkjm8p0vktwitcsm16lny7jzp9t4drwav3qmhz4yjq4k04x14gl6p148hulyqioo72tf8nwrxxcclfypz2lc58lsibgfe5w5p0xv95peafjjmm2frkhdc6duoky0aha"
Faker::Lorem.characters(number: 10) #=> "ang9cbhoa8"
Faker::Lorem.characters(number: 10, min_alpha: 4) #=> "ang9cbhoa8"
Faker::Lorem.characters(number: 10, min_alpha: 4, min_numeric: 1) #=> "ang9cbhoa8"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

lib/faker/default/alphanumeric.rb Outdated Show resolved Hide resolved
@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch 2 times, most recently from 97b9cee to 9e8feb4 Compare August 23, 2019 21:46
@bpleslie
Copy link
Member Author

@Zeragamba @vbrazo I believe I have addressed all of your feedback. Let me know if you see anything else 👍

@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch from 9e8feb4 to 76566d9 Compare August 23, 2019 22:16
@vbrazo vbrazo added this to the 2.2.0 milestone Aug 25, 2019
vbrazo added a commit that referenced this pull request Aug 25, 2019
@vbrazo
Copy link
Member

vbrazo commented Aug 26, 2019

@bpleslie could you rebase and fix the conflicts?

@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch from 76566d9 to 0e8439f Compare August 26, 2019 16:31
@bpleslie bpleslie force-pushed the issue-1673-password-mix-case branch from 0e8439f to 942091a Compare August 26, 2019 16:54
@bpleslie
Copy link
Member Author

@vbrazo we should be all set here

@vbrazo vbrazo merged commit 80e4584 into faker-ruby:master Aug 27, 2019
vbrazo added a commit that referenced this pull request Aug 28, 2019
* Bump to version 2.2.0

* Add #1694
@bpleslie bpleslie deleted the issue-1673-password-mix-case branch September 10, 2019 00:00
michebble pushed a commit to michebble/faker that referenced this pull request Feb 16, 2020
michebble pushed a commit to michebble/faker that referenced this pull request Feb 16, 2020
davidmorton0 pushed a commit to davidmorton0/faker that referenced this pull request Jul 12, 2021
davidmorton0 pushed a commit to davidmorton0/faker that referenced this pull request Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants