dotnet
dotnet copied to clipboard
Add IsCurrency to StringExtensions
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
.
@Sergio0694 Whenever you're ready on this
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!