Mastercard Validator

Mastercard numbers — 16 digits, 51–55 and 2221–2720 ranges, Luhn check.

International Validation Generation

How validation works

The validator checks the Mastercard BIN ranges and length, then applies the Luhn checksum.

Install the package

bash
dotnet add package DocumentNumber.PaymentCardNumber.Mastercard.Validator

Validator in C#

Program.cs
using DocumentNumber.PaymentCardNumber.Mastercard.Validator;

var validator = new MastercardPaymentCardValidator();
var isValid = validator.Validate("5375718830831320");

Console.WriteLine(isValid ? "Valid" : "Invalid");

Live example

5375718830831320 — a real Mastercard value accepted by the validator

Try Mastercard validation

Runs the exact same library code your application uses. Nothing you enter is stored.

Document type Mastercard International
Example: 5375718830831320 — demo input is never stored.

Frequently asked questions

What is Mastercard?

Mastercard numbers — 16 digits, 51–55 and 2221–2720 ranges, Luhn check.

How does Mastercard validation work?

The validator checks the Mastercard BIN ranges and length, then applies the Luhn checksum.

How do I install the Mastercard validator package?

dotnet add package DocumentNumber.PaymentCardNumber.Mastercard.Validator

Is the value I enter in the demo stored?

No. Demo inputs are processed in memory for the current request only and are never persisted or shared.

Related document types