Skip to content

Add IsCurrency to StringExtensions. #72

@Arlodotexe

Description

@Arlodotexe
Member

Continuing from Currency validation support #4430.

We'd like to add an IsCurrency extension method to StringExtensions that bundles an easy and obvious check for if a string is a valid currency, similar to IsDecimal.

This would be implemented like so

public static bool IsCurrency([NotNullWhen(true)] this string? str)
{
    return decimal.TryParse(str, NumberStyles.Currency, out _);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    common 💼Issues/PRs for the Common packagefeature request 📬A request for new changes to improve functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Arlodotexe@Sergio0694

      Issue actions

        Add IsCurrency to StringExtensions. · Issue #72 · CommunityToolkit/dotnet