cjihrig/credit-card ? reverse-engineered prompt

Reverse engineered prompt

Build me a small JavaScript library that checks credit card details.

I want to be able to pass in a card object with things like card type, number, expiry month, expiry year, and CVV, and get back a clean result saying whether each part is valid and whether the card is expired. It should also be able to tell the card type from the number, check the number with the usual checksum rule, verify the month and year are in a valid range, and make sure the CVV length matches the card type.

Please include support for a few common card types, and let me override the defaults or add my own types if needed. It should also work if the input field names are slightly different, as long as I can map them in options. I’d like simple functions I can call directly, plus a main validate function that ties everything together.

Add tests for the main cases, including valid cards, invalid numbers, expired cards, bad CVVs, and custom settings.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab