npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

card-precheck

v0.1.1

Published

**card-precheck** is a lightweight JavaScript utility for validating credit and debit card numbers **before** sending them to a payment gateway.

Readme

card-precheck

card-precheck is a lightweight JavaScript utility for validating credit and debit card numbers before sending them to a payment gateway.

It helps developers catch obviously invalid card input early by applying public industry rules such as checksum validation and card brand patterns. This improves user experience and reduces unnecessary payment API requests.

This package is designed for pre-validation only and is not a replacement for payment processor authorization.


Installation

npm install card-precheck

Basic usage

const { validateCardNumber } = require("card-precheck");

const result = validateCardNumber("4242 4242 4242 4242");

console.log(result);
/*
{
  isValid: true,
  cardType: "visa",
  reason: null
}
*/

What it does

  • Validates card numbers using the Luhn algorithm
  • Identifies card brands based on known prefixes and lengths
  • Rejects malformed or impossible card numbers
  • Works offline with no network calls
  • Can be used client-side or server-side

What it does not do

card-precheck does not:

  • Verify that a card exists
  • Check available funds
  • Perform authorization or charges
  • Validate CVV or expiry dates
  • Detect stolen, blocked, or fraudulent cards

A card that passes validation may still fail when processed by a payment provider. Final verification must always be handled by a PCI-compliant gateway such as Stripe, Paystack, Adyen, or similar services.


Why this exists

When building SaaS products with free trials or delayed billing, developers often want to:

  • Prevent obviously fake card numbers during signup
  • Improve form validation and error feedback
  • Reduce spam or bot-generated inputs
  • Avoid unnecessary calls to payment APIs

card-precheck provides a fast, local way to validate card input before involving a payment processor.


Common use cases

  • Disable form submission until a card number is valid
  • Validate card input during onboarding or trial signup
  • Improve UX with immediate feedback
  • Reduce invalid payment attempts

Security and compliance notes

  • This library does not store, transmit, or log card numbers
  • Avoid logging raw card data in your application
  • Do not rely on this package for fraud prevention
  • Always use a PCI-compliant payment provider for real transactions

Supported card types

  • Visa
  • Mastercard
  • American Express
  • Discover

Philosophy

Credit card validation rules are public knowledge. card-precheck applies these rules clearly and responsibly, without implying bank-level verification or authorization.


Disclaimer

This package performs format and checksum validation only. It provides no guarantees regarding card authenticity, authorization success, or fraud prevention.


License

  • MIT