Test data only. Local fixtures do not issue cards, verify accounts or provide payment authorization. Use them only in authorized tests. Why?
5 test cards
- Generated fields are not uploaded
- Randomly generated in your browser
- Every number passes the Luhn check
Test Visa input without losing a digit
Use this page to check paste handling, length policy and storage precision. The tool starts on Visa and produces 16-digit numbers. It does not generate the 13- or 19-digit fixtures below; those are fixed local test inputs supplied separately so that each run covers the same edge cases.
Start with one generated card for a manual form check. For a regression test, save the fixture files below: changing the quantity or pressing Generate creates fresh values, which is useful for variety but does not reproduce a particular failure.
Visa card number format
The parser in this example accepts a leading 4 and an explicit list of lengths. Its
default profile is [16, 19]; a separate case opts into a legacy 13-digit input. This is a
sample application’s policy, not a rule that every gateway accepts those lengths.
Cybersource’s card identification reference
describes Visa numbers up to 19 digits. Confirm the actual profile with your processor and
SDK before adopting a local allowlist. The Visa format guide
provides the background; this page concentrates on what happens to the input in your code.
| Fixture | What it isolates | Expected result in this example |
|---|---|---|
4539148803436467 | Ordinary 16-digit input | Preserve the exact string |
4539 1488 0343 6467 | Paste with ordinary spaces | Remove spaces, retain all digits |
| The same groups with nonbreaking spaces | Text copied from a formatted document | Normalize the documented separator |
4539-1488-0343-6467 | Hyphen-separated paste | Remove hyphens without changing the number |
4532015112830366187 | 19-digit storage boundary | Preserve all 19 digits through JSON |
4222222222222 | Legacy length configuration | Reject under [16, 19]; accept under [13, 16, 19] |
4539x148803436467 | An unexpected letter | Reject; do not silently erase the letter |
453914880343646 | Truncation to 15 digits | Reject under either profile |
“Accept” here means the input passed this parser’s shape rules. The parser does not run Luhn, identify an issuing account or submit a payment. Test checksum handling separately with the card validator.
Run the paste and round-trip checks
Download Visa input fixtures (JSON) and the runnable Visa checks into the same directory. With Node.js installed, run:
node --test visa-input.test.mjs
The file runs ten input cases plus a precision check without installing a package or calling a service. This excerpt is read directly from that downloadable file; the file also contains its imports, fixture loader and assertions.
function parseVisaInput(value, acceptedLengths) {
if (typeof value !== 'string') return null;
// Accept documented separators, not arbitrary non-digit characters.
const digits = value.replace(/[ \u00a0-]/g, '');
if (!/^4\d+$/.test(digits)) return null;
return acceptedLengths.includes(digits.length) ? digits : null;
}
// The sample profile is a choice: align it with your processor and SDK.
const acceptedLengths = [16, 19];
const number = parseVisaInput('4532 0151 1283 0366 187', acceptedLengths);
const restored = JSON.parse(JSON.stringify({ number }));
assert.equal(restored.number, '4532015112830366187');To test your application, replace parseVisaInput in the downloaded runner with an import
of your own normalization function and keep the fixture expectations. A passing sample
runner demonstrates the contract; it does not prove that your checkout implements it.
The precision failure to reproduce
A card number is an identifier, even when it contains only digits. The 19-digit fixture
exceeds JavaScript’s exact integer range: converting it to Number and back changes its
value. The JavaScript numeric limit
explains why this is a data-type problem, not a checksum problem.
Keep the number, expiry components and CVV as strings when adapting the generator’s JSON. For CSV imports, set the number and CVV columns to text before importing; quoting a CSV cell alone does not force a spreadsheet to preserve its type. The bulk generator documents the export schemas for larger sets.
Manual checkout exercise
- Paste the 19-digit fixture into your development form, then blur and refocus the field.
Compare the unformatted value before and after: neither a mask nor
maxlengthshould silently remove the final three digits. - Paste the same input with spaces. Check the submitted test payload, not only the visible mask; a correct-looking field can still serialize the wrong value.
- Insert
xbetween digit groups. Confirm your chosen validation policy reports invalid input instead of quietly constructing a different number. - Save the fixture through your application’s local test persistence layer, reload it and compare the entire string. A test that compares only the last four digits misses this bug.
For an input-length defect, record the raw pasted string, configured length profile, normalized value and round-trip value in the failing test. This distinguishes an input-mask problem from numeric coercion further down the pipeline.
When the test crosses into a payment gateway
Use provider fixtures for approval, decline and authentication responses. A generated Visa number does not stand in for a registered sandbox card. The gateway test-card reference keeps those provider-specific cases separate from these local input tests.
If the defect appears only after switching brands, use the Amex transition tests. If it is a prefix boundary rather than a length problem, use the Mastercard range tests.