-
Notifications
You must be signed in to change notification settings - Fork 1
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
Change isnumeric to isdigit in NumericValidator #376
Conversation
@@ -256,7 +256,7 @@ def __init__(self, min_numeric=0): | |||
self.min_numeric = min_numeric | |||
|
|||
def validate(self, password, user=None): | |||
if _validate_condition(password, lambda c: c.isnumeric(), self.min_numeric): | |||
if _validate_condition(password, lambda c: c.isdigit(), self.min_numeric): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but are both of these actually the same things ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are changing the edx's code, we should make sure that we are doing exactly what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are only referring to the NumericValidator
that checks if the digit is number or not. So, yes isdigit()
and isnumeric()
both serve the same purpose here. I have added a Django code Reference link in PR description Django itself uses isdigit()
.
If you have anything else in mind, let me know I will try that use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this documentation: Link
They can work differently in some scenarios like different languages or Unicode numeric characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then i think everything's cool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danialmalik Created a PR in edX: https://github.com/edx/edx-platform/pull/24197
Let's see. 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Booooyaah 😃
thanks for your quick work on this! one other error i ran into was the following in PunctuationValidator class (original and new code below): #if _validate_condition(password, lambda c: ‘P’ in unicodedata.category(c), self.min_punctuation): |
Issue:
isnumeric()
only works on Unicode characters. If we run the commandchangepassword
:It gives us error:
We can use
isdigit()
it works on bothstr
andUnicode
. Django itself useisdigit()
in it's NumericValidator. Reference Link