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

Checking if market is a valid ISO 3166-1 alpha-2 country code needs to be negated #182

Open
karjamatti opened this issue Aug 31, 2022 · 0 comments
Assignees
Labels

Comments

@karjamatti
Copy link

These functions

get_show()
get_shows()
get_show_episodes()
get_album()
get_albums()
get_album_tracks()
get_my_saved_albums()

that have the following check:

if (str_detect(market, '^[[:alpha:]]{2}$')) {
            stop('"market" must be an ISO 3166-1 alpha-2 country code')
}

Where the logical test needs to be negated, like so:

if (!str_detect(market, '^[[:alpha:]]{2}$')) {
            stop('"market" must be an ISO 3166-1 alpha-2 country code')
}

Since it's now raising an error when market is indeed in the correct format.

The negated version of the check s is already correctly implemented in the following functions:

get_artist_albums()
get_artist_top_tracks()

Moreover, the search_spotify() ad validate_market() functions use a different approach, which I like even better tbh:

   if (!is.null(market)) {
        assertthat::assert_that(
            str_detect(market, '^[[:alpha:]]{2}$'),
            msg = "The parameter 'market' must be an ISO 3166-1 alpha-2 country code."
        )
    }
@antaldaniel antaldaniel self-assigned this Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants