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

CreditCardType is not accessible although it's used as a parameter to a public method #860

Closed
SaraMahdy opened this issue Jun 12, 2023 · 13 comments

Comments

@SaraMahdy
Copy link

Describe the bug
CreditCardType enum has recently changed to be internal instead of external. This breaks any code that either uses the enum directly or the public method creditCard(CreditCardType creditCardType).

Expected behavior
CreditCardType be exposed to public.

@SaraMahdy SaraMahdy changed the title CreditCardType is not accessible although it's used as a param to a public method CreditCardType is not accessible although it's used as a parameter to a public method Jun 12, 2023
@snuyanzin
Copy link
Collaborator

yes, that is not good
however could you please elaborate more what is the use case to use this method while using datafaker?
I thought creditCard() should be ebough

@SaraMahdy
Copy link
Author

Thanks for your reply!

So we use creditCard() to generate valid PANs to use in the tests, now the generated PAN depends on the credit card type, e.g 16 digits for Mastercard and Visa but it's 15 digits for Amex. So we used to pass the credit card type to creditCard() to get a valid PAN for that specific type.

@bodiam
Copy link
Contributor

bodiam commented Jun 12, 2023

I haven't checked yet, but does this affect both the 1.x and 2.x versions?

@SaraMahdy
Copy link
Author

It affects only 2.x versions

@bodiam
Copy link
Contributor

bodiam commented Jun 12, 2023

I can release a 2.0.1 for this tomorrow.

@snuyanzin
Copy link
Collaborator

snuyanzin commented Jun 12, 2023

looks like only 2.x
the fastest way for users is to create a class (in same package like net.datafaker.providers.base.<yourClassnameHere>) and extending Finance.
Since CreditCardType has package private access it will be possible to access CreditCardType from this new class.

So far it could be considered as a WA

@redhell
Copy link
Contributor

redhell commented Jun 13, 2023

Revert the part of #786 where it is moved to an internal class.
For my applications it's neccessary to switch between creditcard types.

@bodiam Please release a 2.0.1. with reverting the mentioned change

@bodiam
Copy link
Contributor

bodiam commented Jun 13, 2023

Interesting: I'm sure I did that that change for a reason, I just don't remember what the reason was. I remember that I did it because all the classes in that package are Providers, except for CreditCardType.

If I make the enum public, but keep it inside the Finance class, would that work for you? (I think the import will change a little, but that's it)

@bodiam
Copy link
Contributor

bodiam commented Jun 13, 2023

The same issue seemed to affect Compass. I fixed both of them here:

#861

I'll merge them. After the merge, could you try out the 2.0.1-SNAPSHOT version? If that works well, I'll release it.

@redhell
Copy link
Contributor

redhell commented Jun 17, 2023

Works for me 👍

@kingthorin
Copy link
Collaborator

Thanks for confirming.

@bodiam
Copy link
Contributor

bodiam commented Jun 17, 2023

Thanks, I'll make a new release tomorrow!

@bodiam
Copy link
Contributor

bodiam commented Jun 18, 2023

2.0.1 has been released, which should fix this issue. Thanks again for reporting and testing it!

@bodiam bodiam closed this as completed Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants