-
Notifications
You must be signed in to change notification settings - Fork 155
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
feat: improve the PIN Enter repetition validation rule and add relevant messages #1401
base: main
Are you sure you want to change the base?
Conversation
…nt messages Signed-off-by: Jian Wang <[email protected]>
Signed-off-by: Jian Wang <[email protected]>
Signed-off-by: Jian Wang <[email protected]>
Signed-off-by: Jian Wang <[email protected]>
@@ -71,7 +71,7 @@ export const PINRules: PINValidationRules = { | |||
only_numbers: true, | |||
min_length: 6, | |||
max_length: 6, | |||
no_repeated_numbers: false, |
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.
I know this is in draft but if it's doable could we keep the defaults the same and just allow for opt-in behavior with the injectable PINSecurity.rules
config we have currently?
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.
Put both PINSecurity and PINCreationValidation to IoC container, then the wallet variants can customize them without changinf Bifold default validating behavior. I will discuss with team. Thanks @bryce-mcmath
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.
Back to default, but change the validating logic for '0' as 'repeating times' instead of its boolean value, keep the extra message for numbers repeating allowed but the repeating times exceeding the max times rule
…refactored the messages Signed-off-by: Jian Wang <[email protected]>
Signed-off-by: Jian Wang <[email protected]>
…lidation message and change the logic of '0' in no_repeated_behavior Signed-off-by: Jian Wang <[email protected]>
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.
I did have one question out of curiosity but it seems to still work either way. Nice going!
noRepeatedNumbers = new RegExp(`(\\d)\\1{${PINRules.no_repeated_numbers - 1},}`) | ||
} | ||
|
||
if ('number' === typeof(PINRules.no_repeated_numbers) && PINRules.no_repeated_numbers > 2 ) { |
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.
When would the > 2
check be needed at the same time as the string interpolation below is? Wouldn't there only be one case (3) where that condition is satisfied?
@@ -77,7 +77,7 @@ describe('PIN creation validations', () => { | |||
test('PIN with repeated numbers and repeated numbers validation to true, so the validation use the default of two repeated numbers, should return NoRepetitionOfTheSameNumbersValidation as invalid', async () => { | |||
const PINRulesWithRepeatedNumbers = { | |||
...defaultPINRules, | |||
no_repeated_numbers: true, | |||
no_repeated_numbers: 0, |
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.
I think no_
should be change to num_
if it now indicates the number of of repeating values allowed.
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.
@jleach Good point, It is type 'boolean | number'
now. I changed it to an enum [1,2,3,4 ...]
type in the Draft version for discussing and then changed it back. Actually I still think maxRepetition number is an option.
@bryce-mcmath If you think we need more discussion, I will pull this feat back to draft
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.
@jian4on ah right, the type changed. num
is good I think, we can change the default since the type is changing. maybe just add a note in the "Breaking changes" section of the description of this PR so other teams know what to change to keep their existing behavior
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.
Not sure this will work well. There will be no way to disable the rule unless another flag is added. You can put in a high number but that will then be displayed during password selection, which would be confusing for the user.
…e rule 'max_repeated_numbers', and refactor the test cases relevently Signed-off-by: Jian Wang <[email protected]>
|
Summary of Changes
Change the PIN repetition validation to a number type rule 'max_repeated_numbers' to make the repeated-times validation setting more readable
Screenshots, videos, or gifs
N/A
Breaking change guide
The previous 'no_repeated_numbers' was an union type 'boolean | number', it is changed to a number and the rule name is changed too. The default validation setting was 'false' for allowing repeating, it is '5' for the new 'max_repeated_numbers' rule, so that repeating keep allowed for 6 digital PINs.
The validating behaviours are following the rule label exactly now, don't implement boolean value.
0: No adjacent numbers repeating allowed
n > 0: Maximum repeating times, e.g. '1 === n' for "11" allowed but "111" forbidden
Related Issues
N/A
Pull Request Checklist
Tick all boxes below to demonstrate that you have completed the respective task. If the item does not apply to your this PR check it anyway to make it apparent that there's nothing to do.
Signed-off-by
line (we use the DCO GitHub app to enforce this)If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!
Pro Tip 🤓