Skip to content

Fix password generator length validation - #15757

Open
dbhoopesh1-tech wants to merge 1 commit into
TheAlgorithms:masterfrom
dbhoopesh1-tech:master
Open

dbhoopesh1-tech wants to merge 1 commit into
TheAlgorithms:masterfrom
dbhoopesh1-tech:master

Conversation

@dbhoopesh1-tech

Copy link
Copy Markdown

Add validation for minimum password length requirement.

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

Add validation for minimum password length requirement.
@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files tests are failing Do not merge until tests pass labels Nov 13, 2026

@Mohit-Gaur75 Mohit-Gaur75 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for working on this validation!

There is an IndentationError in the if block where raise ValueError is not indented 8 spaces (4 spaces deeper than if), which is why the ruff and build CI checks are failing.

Please see the suggestion below to fix the indentation. Additionally, per the repository's contributing guidelines, consider adding a doctest to demonstrate this ValueError when i < len(chars_incl).

Comment thread other/password.py
Comment on lines +32 to +35
if i < len(chars_incl):
raise ValueError(
"Password length must be at least the number of required characters"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if i < len(chars_incl):
raise ValueError(
"Password length must be at least the number of required characters"
)
if i < len(chars_incl):
raise ValueError(
"Password length must be at least the number of required characters"
)

The raise ValueError block must be indented under the if statement to avoid an IndentationError.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants