-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add support for 8 digit IINs and 2 digit last_digits #123
Conversation
48b7b0e
to
7738b8a
Compare
)); | ||
parent::__construct( | ||
v::allOf( | ||
v::when( |
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.
This doesn't feel like it belongs in the parameter list, but I wasn't familiar enough with this to determine how to express it more clearly. I assumed I would be able to apply the 2|4 valuation on last_digits in the parameter list and do additional validation based on the iin inside the function body but I couldn't get it to DWIM
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.
Yeah, that is a tricky one. I thought OneOf
might work well here, but on reflection, we have to also handle the case where the keys aren't present. One possible improvement might be switching the When
to:
v::when(
v::key('issuer_id_number', v::stringType()->length(8, 8), false),
v::key('last_digits', v::stringType()->length(2, 2), false),
v::key('last_digits', v::stringType()->length(4, 4), false),
),
And moving the last_digits
validation down. This should improve the error message and might make it a little bit easier to understand the logic.
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.
One comment. I'll leave it up to you whether you want to make the change.
)); | ||
parent::__construct( | ||
v::allOf( | ||
v::when( |
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.
Yeah, that is a tricky one. I thought OneOf
might work well here, but on reflection, we have to also handle the case where the keys aren't present. One possible improvement might be switching the When
to:
v::when(
v::key('issuer_id_number', v::stringType()->length(8, 8), false),
v::key('last_digits', v::stringType()->length(2, 2), false),
v::key('last_digits', v::stringType()->length(4, 4), false),
),
And moving the last_digits
validation down. This should improve the error message and might make it a little bit easier to understand the logic.
Previously issuer_id_number was expected to be 6 digits and last_4_digits to be 4 digits. This changes the validation to additionally allow for 8 digit issuer_id_numbers and 2 digit last_4_digits. Additionally last_4_digits has been deprecated in favor of the more appropriately named last_digits.
55865b9
to
1e4aa83
Compare
8aa20b6
to
5375e27
Compare
@oschwald our credit card provider only returns the last 2 not 4 digits of a masked credit card so this PR is of interest for us. Do you have any idea when you will be tagging a new release? |
@mrtimp, I suspect we will be releasing this in the very near future, perhaps the next week or two. |
Fantastic @oschwald! Look forward to it. |
Previously issuer_id_number was expected to be 6 digits and
last_4_digits to be 4 digits. This changes the validation to
additionally allow for 8 digit issuer_id_numbers and 2 digit
last_4_digits.
Additionally last_4_digits has been deprecated in favor of the
more appropriately named last_digits.