Choose a card type
How many?
1

Test data only. Local fixtures do not issue cards, verify accounts or provide payment authorization. Use them only in authorized tests. Why?

VisaTEST CARD
•••• •••• •••• ••••
Cardholder—
ExpiresMM/YY
CVV•••
  • 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 prefixCandidates in this fixtureExpected local result
50 or 56MaestroMaestro
6304, 6759 or 6763Maestro, possibly from more than one ruleMaestro; duplicate same-brand matches are not a conflict
6011, 644 or 65Discover and MaestroDiscover from the more specific configured rule
62Maestro and UnionPayUnionPay from the more specific configured rule
81UnionPayUnionPay
51MastercardMastercard comparison case
6759 with an added equally specific alternate-brand ruleMaestro and the synthetic alternateAmbiguous; 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.

Frequently Asked Questions

Why does the fixture contain a broad Maestro 6 rule?
It deliberately recreates a fallback that can overlap more specific patterns. It is a test configuration, not a statement that every number starting with 6 is Maestro.
What should happen if two equally specific rules disagree?
The sample returns ambiguous with no selected brand. Reordering the rules must not hide the conflict. Resolve the configuration or use the provider’s authoritative response before making acceptance or routing decisions.
Does the sample decide whether a security code is required?
No. Follow the field requirements of the provider and product you integrate with. Neither a Maestro label nor a generated security code proves that the field can be omitted.
Which lengths and prefixes does this generator produce?
It randomly selects 16 or 19 digits and uses 50, 56–58, 6304, 6759 or 6761–6763. It has no per-length or per-prefix selector and does not cover every Maestro product.