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

Add IsCurrency to StringExtensions #73

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Arlodotexe
Copy link
Member

Closes #72.

Adds an IsCurrency extension method to StringExtensions that bundles an easy and obvious check for if a string is a valid currency, similar to IsDecimal.

@Arlodotexe
Copy link
Member Author

@Sergio0694 Whenever you're ready on this

@faiteanu
Copy link

Hi, I'd like to draw the attention to several issues with this PR and would request to consider before merging it.

Does the name IsCurrency follow the .NET naming guidelines, specifically regarding misleading names? I would expect

"USD".IsCurrency == true;
"US Dollar".IsCurrency == true;
"MX".IsCurrency == false;

Your use of the word "currency" sounds non-standard. Maybe IsCurrencyWithAmount.

What is the global / world-wide use case, apart from your specific local use? IMO dealing with currency amounts without regarding the actual currency is a source for disaster.
General tutorials give formatting examples like:

// Default US Currency Format
string.Format(new CultureInfo("en-US"), "{0:C}", 1456.12155)      // $1,456.12
// Currency format for Mexico
string.Format(new CultureInfo("es-MX"), "{0:C}", 1456.12155)      // 1.456,12 Mex$

Please never ever write such code in a public application! If a price is 1,456.12 US Dollars, a customer cannot just pay 1.456,12 Mexican Pesos instead, just because he changed the language in his browser or operating system!

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

Successfully merging this pull request may close these issues.

Add IsCurrency to StringExtensions.
4 participants