crobertsbmw / deckofcards

An API to simulate a deck of cards
MIT License
1.34k stars 335 forks source link

Shuffle a number of negative decks #126

Closed Mesquitigor closed 11 months ago

Mesquitigor commented 1 year ago

Like if you try to shuffle -10 decks, the API undertands it like normal and proceed the request normaly and responds 200 OK. image

crobertsbmw commented 1 year ago

Oh, that's interesting. What would the intended behaviour here be?

On Mon, Nov 21, 2022 at 3:17 PM Higor Mesquita @.***> wrote:

Like if you try to shuffle -10 decks, the API undertands it like normal and proceed the request normaly and responds 200 OK. [image: image] https://user-images.githubusercontent.com/80482870/203169227-82a65f46-143a-4a39-8c8e-b441800e01c8.png

— Reply to this email directly, view it on GitHub https://github.com/crobertsbmw/deckofcards/issues/126, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMQLHU6W6LD7UEUV5TRMXDWJPYH3ANCNFSM6AAAAAASHDV2Y4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Mesquitigor commented 1 year ago

I think that the right behaviour for this case is to respond 400 as status code and response or something like this. I think it's not correct the response for wrong request be 200 and OK and the fields respond ""success":true". Do you agree?

chrismahoney commented 11 months ago

The mental image of somebody attempting to somehow shuffle -10 decks is pretty funny though... haha

crobertsbmw commented 11 months ago

When looking into this, I saw that there's already a check for >20 decks, so I just followed that pattern, and added another check for <1 deck. Consider this squashed.