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
Make overlapping brand rules explain their result
When two rules match the same input, a detector that returns the first match can change behavior after a harmless-looking refactor. The useful Maestro regression is therefore a candidate trace: record every matching brand, identify the most specific match, and leave equal-specificity conflicts unresolved.
The generator produces 16- or 19-digit Luhn-valid strings using 50, 56–58, 6304,
6759 or 6761–6763. Length and prefix are selected randomly. The downloadable fixture
adds other brands as comparison inputs; choosing Maestro in the tool will not generate them.
Recreate the first-match defect
Our fixture deliberately includes a broad 6 → Maestro fallback plus a small set of
specific rules. A 6011 input matches both that fallback and a Discover rule. A 62 input
matches both the fallback and a UnionPay rule. Returning the first array entry makes the
result depend on rule order rather than the configured prefix specificity.
This is an illustrative configuration, not an issuer allocation table. Braintree describes stronger-pattern matching in its detector documentation. The example below adopts that idea for complete digit strings and explicitly reports ties; it does not reproduce the library’s full data or partial-input behavior.
For a number still being typed, use the JCB input-state exercise to distinguish a possible prefix from a completed shape before resolving the full input.
| Input prefix | Candidates in this fixture | Expected local result |
|---|---|---|
50 or 56 | Maestro | Maestro |
6304, 6759 or 6763 | Maestro, possibly from more than one rule | Maestro; duplicate same-brand matches are not a conflict |
6011, 644 or 65 | Discover and Maestro | Discover from the more specific configured rule |
62 | Maestro and UnionPay | UnionPay from the more specific configured rule |
81 | UnionPay | UnionPay |
51 | Mastercard | Mastercard comparison case |
6759 with an added equally specific alternate-brand rule | Maestro and the synthetic alternate | Ambiguous; no selected brand |
Use Discover coverage fixtures if your question is whether all configured prefix branches were exercised. This test asks a different question: whether a competing fallback can change the answer.
Run the detector with reversed rules
Download the rules and candidate expectations and the resolution checks together:
node --test maestro-candidates.test.mjs
Each fixture records the expected selected brand and the complete candidate list. The runner reverses the rule array and repeats every assertion, adds an equal-specificity conflict, duplicates a same-brand rule, and checks an empty rule configuration.
function resolveCandidates(number, rules) {
if (typeof number !== 'string' || !/^[0-9]{12,19}$/.test(number)) {
return { status: 'invalid-input', brand: null, candidates: [] };
}
const matches = rules.filter(rule => number.startsWith(rule.prefix));
const candidates = [...new Set(matches.map(rule => rule.brand))].sort();
if (matches.length === 0) return { status: 'unmapped', brand: null, candidates };
const strongest = Math.max(...matches.map(rule => rule.prefix.length));
const winners = [...new Set(matches.filter(rule => rule.prefix.length === strongest)
.map(rule => rule.brand))];
return winners.length === 1
? { status: 'matched', brand: winners[0], candidates }
: { status: 'ambiguous', brand: null, candidates };
}The sample takes 12–19 digits as its input envelope for this local resolution exercise.
That is not a promise that every brand accepts every length in that envelope. Length
validation, Luhn and provider acceptance remain separate checks. Inputs outside the small
rule set return unmapped, not “no such card.”
Turn a candidate trace into a useful failure report
Adapt resolveCandidates to call your own detector and compare the selected brand first.
If your detector exposes candidate information, compare that too. A failure should record
the fixture ID, matching rule prefixes and selected result, making it clear whether a
specific rule is missing or an earlier broad rule wins incorrectly.
For production integrations, keep the provider’s maintained brand information authoritative where it supplies the answer. Do not derive account funding from this prefix model; the debit funding exercise uses explicit response data for that. The BIN lookup explanation covers the limits of a local pattern match.
Keep a security-code requirement separate as well. This generator always supplies a three-digit synthetic value, and the resolver never decides whether a code is required. Test that requirement against your provider’s contract instead of making the field optional for every Maestro candidate.
Finally, inspect the displayed brand after a rule-set update and after a dependency update. An ambiguity should not silently become a confident logo or an acceptance promise. Use the sandbox reference to test provider responses after the local candidate-resolution assertions pass.